feat: 🎸 base indices for pagination

This commit is contained in:
amianthus
2026-05-13 13:58:20 +01:00
parent 013a9e7837
commit 3508b56315
3 changed files with 16 additions and 1 deletions

View File

@@ -89,6 +89,12 @@ export const customers = pgTable(
table.env,
sql`${table.created_at} DESC`,
),
index("idx_customers_cursor").on(
table.org_id,
table.env,
sql`${table.created_at} DESC`,
sql`${table.id} DESC`,
),
index("idx_customers_processors_revenuecat").on(
sql`(${table.processors} ->> 'revenuecat')`,
),

View File

@@ -70,5 +70,11 @@ export const entities = pgTable(
table.env,
table.id,
),
index("idx_entities_cursor").on(
table.org_id,
table.env,
sql`${table.created_at} DESC`,
sql`${table.id} DESC`,
),
],
);

View File

@@ -1,4 +1,4 @@
import type { InferInsertModel, InferSelectModel } from "drizzle-orm";
import { sql, type InferInsertModel, type InferSelectModel } from "drizzle-orm";
import {
boolean,
foreignKey,
@@ -111,6 +111,9 @@ export const customerProducts = pgTable(
index("idx_customer_products_stripe_checkout_session_id").on(
table.stripe_checkout_session_id,
),
index("idx_customer_products_revenuecat_processor")
.on(table.internal_customer_id)
.where(sql`(${table.processor} ->> 'type') = 'revenuecat'`),
],
);