feat: 🎸 base indices for pagination
This commit is contained in:
@@ -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')`,
|
||||
),
|
||||
|
||||
@@ -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`,
|
||||
),
|
||||
],
|
||||
);
|
||||
|
||||
@@ -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'`),
|
||||
],
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user