feat: add partnerLicenseKey and partnerTier to subscription schema

This commit is contained in:
Henry
2026-05-12 21:34:01 +01:00
parent 4459fbb4b2
commit e34518e654
4 changed files with 4002 additions and 20 deletions

View File

@@ -0,0 +1,3 @@
ALTER TABLE "subscription" ADD COLUMN "partnerLicenseKey" varchar(255);--> statement-breakpoint
ALTER TABLE "subscription" ADD COLUMN "partnerTier" integer;--> statement-breakpoint
CREATE UNIQUE INDEX IF NOT EXISTS "subscription_partner_license_key_idx" ON "subscription" USING btree ("partnerLicenseKey");

File diff suppressed because it is too large Load Diff

View File

@@ -232,6 +232,19 @@
"when": 1776809379931, "when": 1776809379931,
"tag": "20260421220939_AddCardNumber", "tag": "20260421220939_AddCardNumber",
"breakpoints": true "breakpoints": true
},
{
"idx": 33,
"version": "7",
"when": 1778600989523,
"breakpoints": true
},
{
"idx": 34,
"version": "7",
"when": 1778617946519,
"tag": "20260512203226_AddPartnerLicenseToSubscription",
"breakpoints": true
} }
] ]
} }

View File

@@ -5,31 +5,42 @@ import {
integer, integer,
pgTable, pgTable,
timestamp, timestamp,
uniqueIndex,
varchar, varchar,
} from "drizzle-orm/pg-core"; } from "drizzle-orm/pg-core";
import { workspaces } from "./workspaces"; import { workspaces } from "./workspaces";
export const subscription = pgTable("subscription", { export const subscription = pgTable(
id: bigserial("id", { mode: "number" }).primaryKey(), "subscription",
plan: varchar("plan", { length: 255 }).notNull(), {
referenceId: varchar("referenceId", { length: 12 }).references( id: bigserial("id", { mode: "number" }).primaryKey(),
() => workspaces.publicId, plan: varchar("plan", { length: 255 }).notNull(),
{ onDelete: "set null" }, referenceId: varchar("referenceId", { length: 12 }).references(
), () => workspaces.publicId,
stripeCustomerId: varchar("stripeCustomerId", { length: 255 }), { onDelete: "set null" },
stripeSubscriptionId: varchar("stripeSubscriptionId", { length: 255 }), ),
status: varchar("status", { length: 255 }).notNull(), stripeCustomerId: varchar("stripeCustomerId", { length: 255 }),
periodStart: timestamp("periodStart"), stripeSubscriptionId: varchar("stripeSubscriptionId", { length: 255 }),
periodEnd: timestamp("periodEnd"), status: varchar("status", { length: 255 }).notNull(),
cancelAtPeriodEnd: boolean("cancelAtPeriodEnd"), periodStart: timestamp("periodStart"),
seats: integer("seats"), periodEnd: timestamp("periodEnd"),
unlimitedSeats: boolean("unlimitedSeats").default(false).notNull(), cancelAtPeriodEnd: boolean("cancelAtPeriodEnd"),
trialStart: timestamp("trialStart"), seats: integer("seats"),
trialEnd: timestamp("trialEnd"), unlimitedSeats: boolean("unlimitedSeats").default(false).notNull(),
createdAt: timestamp("createdAt").notNull().defaultNow(), trialStart: timestamp("trialStart"),
updatedAt: timestamp("updatedAt").notNull().defaultNow(), trialEnd: timestamp("trialEnd"),
}).enableRLS(); partnerLicenseKey: varchar("partnerLicenseKey", { length: 255 }),
partnerTier: integer("partnerTier"),
createdAt: timestamp("createdAt").notNull().defaultNow(),
updatedAt: timestamp("updatedAt").notNull().defaultNow(),
},
(table) => [
uniqueIndex("subscription_partner_license_key_idx").on(
table.partnerLicenseKey,
),
],
).enableRLS();
export const subscriptionsRelations = relations(subscription, ({ one }) => ({ export const subscriptionsRelations = relations(subscription, ({ one }) => ({
workspace: one(workspaces, { workspace: one(workspaces, {