* feat: add migration to remove not null constraint from referenceId on subscriptions * feat(cloud): write worspace slug availability checks to db * feat: add migration to add cascade set null to referenceId on subscription * feat: update workspace and subscripton schema * feat: add createWorkspaceSlugCheck repo func * feat: set workspace url on creation * chore: update translations * refactor: various tweaks and fixes * feat: add pro bolt to pricing notice * feat: toggle pro subscription * fix: hide pro subscription notice for self hosters * feat: add pro upgrade message on members page * feat: hide pro upgrade notice on small viewports * feat: update workspace url placeholder
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { relations } from "drizzle-orm";
|
|
import {
|
|
bigserial,
|
|
boolean,
|
|
integer,
|
|
pgTable,
|
|
timestamp,
|
|
varchar,
|
|
} from "drizzle-orm/pg-core";
|
|
|
|
import { workspaces } from "./workspaces";
|
|
|
|
export const subscription = pgTable("subscription", {
|
|
id: bigserial("id", { mode: "number" }).primaryKey(),
|
|
plan: varchar("plan", { length: 255 }).notNull(),
|
|
referenceId: varchar("referenceId", { length: 12 }).references(
|
|
() => workspaces.publicId,
|
|
{ onDelete: "set null" },
|
|
),
|
|
stripeCustomerId: varchar("stripeCustomerId", { length: 255 }),
|
|
stripeSubscriptionId: varchar("stripeSubscriptionId", { length: 255 }),
|
|
status: varchar("status", { length: 255 }).notNull(),
|
|
periodStart: timestamp("periodStart"),
|
|
periodEnd: timestamp("periodEnd"),
|
|
cancelAtPeriodEnd: boolean("cancelAtPeriodEnd"),
|
|
seats: integer("seats"),
|
|
unlimitedSeats: boolean("unlimitedSeats").default(false).notNull(),
|
|
trialStart: timestamp("trialStart"),
|
|
trialEnd: timestamp("trialEnd"),
|
|
createdAt: timestamp("createdAt").notNull().defaultNow(),
|
|
updatedAt: timestamp("updatedAt").notNull().defaultNow(),
|
|
}).enableRLS();
|
|
|
|
export const subscriptionsRelations = relations(subscription, ({ one }) => ({
|
|
workspace: one(workspaces, {
|
|
fields: [subscription.referenceId],
|
|
references: [workspaces.publicId],
|
|
}),
|
|
}));
|