fix slow queries
This commit is contained in:
parent
3016830e25
commit
ef7f712867
4 changed files with 3239 additions and 2 deletions
|
|
@ -0,0 +1,2 @@
|
||||||
|
CREATE UNIQUE INDEX `global_lite_subscription_id` ON `billing` (`lite_subscription_id`);--> statement-breakpoint
|
||||||
|
CREATE INDEX `referral_id` ON `referral_reward` (`referral_id`);
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -53,6 +53,7 @@ export const BillingTable = mysqlTable(
|
||||||
...workspaceIndexes(table),
|
...workspaceIndexes(table),
|
||||||
uniqueIndex("global_customer_id").on(table.customerID),
|
uniqueIndex("global_customer_id").on(table.customerID),
|
||||||
uniqueIndex("global_subscription_id").on(table.subscriptionID),
|
uniqueIndex("global_subscription_id").on(table.subscriptionID),
|
||||||
|
uniqueIndex("global_lite_subscription_id").on(table.liteSubscriptionID),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { bigint, mysqlTable, primaryKey, uniqueIndex, varchar } from "drizzle-orm/mysql-core"
|
import { bigint, index, mysqlTable, primaryKey, uniqueIndex, varchar } from "drizzle-orm/mysql-core"
|
||||||
import { timestamps, ulid, utc, workspaceColumns } from "../drizzle/types"
|
import { timestamps, ulid, utc, workspaceColumns } from "../drizzle/types"
|
||||||
import { workspaceIndexes } from "./workspace.sql"
|
import { workspaceIndexes } from "./workspace.sql"
|
||||||
|
|
||||||
|
|
@ -31,5 +31,8 @@ export const ReferralRewardTable = mysqlTable(
|
||||||
amount: bigint("amount", { mode: "number" }).notNull(),
|
amount: bigint("amount", { mode: "number" }).notNull(),
|
||||||
timeApplied: utc("time_applied"),
|
timeApplied: utc("time_applied"),
|
||||||
},
|
},
|
||||||
(table) => [primaryKey({ columns: [table.workspaceID, table.referralID] })],
|
(table) => [
|
||||||
|
primaryKey({ columns: [table.workspaceID, table.referralID] }),
|
||||||
|
index("referral_id").on(table.referralID),
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue