Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: add organization SSO schema and identity primitives

Richie McIlroy5a29259515de
diff --git a/apps/web/__tests__/unit/sso-state.test.ts b/apps/web/__tests__/unit/sso-state.test.ts
new file mode 100644
index 000000000..a72ea43ab
--- /dev/null
+++ b/apps/web/__tests__/unit/sso-state.test.ts
@@ -0,0 +1,140 @@
+import { createHmac } from "node:crypto";
+import {
+ createSsoLoginIntent,
+ ssoIntentCookie,
+ ssoLoginErrorPath,
+ verifySsoLoginIntent,
+} from "@cap/database/auth/sso-state";
+import { describe, expect, it } from "vitest";
+
+const secret = "test-sso-intent-secret-with-sufficient-entropy";
+const now = Date.UTC(2026, 8, 2, 12);
+const context = {
+ organizationId: "caporganization",
+ workosOrganizationId: "org_verified",
+ connectionId: "conn_verified",
+ actorId: "signedinuser123",
+};
+
+function signedPayload(payload: unknown) {
+ const encoded = Buffer.from(JSON.stringify(payload)).toString("base64url");
+ return `${encoded}.${createHmac("sha256", secret).update(encoded).digest("base64url")}`;
+}
+
+describe("SSO login intent", () => {
+ it("binds the tenant, connection, and existing account with a fresh nonce", () => {
+ const first = createSsoLoginIntent(context, secret, now);
+ const second = createSsoLoginIntent(context, secret, now);
+ expect(first).not.toBe(second);
+ expect(verifySsoLoginIntent(first, secret, now)).toMatchObject(context);
+ });
+
+ it("preserves an anonymous sign-in instead of accepting a later account", () => {
+ const value = createSsoLoginIntent(
+ { ...context, actorId: null },
+ secret,
+ now,
+ );
+ expect(verifySsoLoginIntent(value, secret, now)?.actorId).toBeNull();
+ });
+
+ it("rejects a substituted organization even when the rest of the cookie matches", () => {
+ const value = createSsoLoginIntent(context, secret, now);
+ const [encoded, signature] = value.split(".");
+ const payload = JSON.parse(
+ Buffer.from(encoded ?? "", "base64url").toString(),
+ );
+ payload.workosOrganizationId = "org_attacker";
+ const substituted = Buffer.from(JSON.stringify(payload)).toString(
+ "base64url",
+ );
+ expect(
+ verifySsoLoginIntent(`${substituted}.${signature}`, secret, now),
+ ).toBeNull();
+ });
+
+ it("rejects a wrong signing key and malformed signature without throwing", () => {
+ const value = createSsoLoginIntent(context, secret, now);
+ expect(verifySsoLoginIntent(value, "other-secret", now)).toBeNull();
+ expect(verifySsoLoginIntent(`${value}extra`, secret, now)).toBeNull();
+ expect(verifySsoLoginIntent(`${value}.extra`, secret, now)).toBeNull();
+ });
+
+ it("expires at ten minutes and permits only a small future clock skew", () => {
+ const value = createSsoLoginIntent(context, secret, now);
+ expect(verifySsoLoginIntent(value, secret, now + 599_000)).not.toBeNull();
+ expect(verifySsoLoginIntent(value, secret, now + 600_000)).toBeNull();
+ expect(verifySsoLoginIntent(value, secret, now - 31_000)).toBeNull();
+ });
+
+ it("preserves a same-origin app continuation through SSO error recovery", () => {
+ const returnTo = "/api/mobile/session/request?redirectUri=cap%3A%2F%2Fauth";
+ const value = createSsoLoginIntent({ ...context, returnTo }, secret, now);
+ expect(verifySsoLoginIntent(value, secret, now)?.returnTo).toBe(returnTo);
+ const errorUrl = new URL(
+ ssoLoginErrorPath("SsoSignInFailed", returnTo),
+ "https://cap.test",
+ );
+ expect(errorUrl.searchParams.get("next")).toBe(returnTo);
+ expect(errorUrl.searchParams.get("error")).toBe("SsoSignInFailed");
+ });
+
+ it.each([
+ "https://attacker.example/",
+ "//attacker.example/",
+ "/\\attacker.example/",
+ "/.//attacker.example/",
+ "/\n/attacker.example/",
+ `/${"a".repeat(1024)}`,
+ ])("discards unsafe or oversized return paths: %j", (returnTo) => {
+ const value = createSsoLoginIntent({ ...context, returnTo }, secret, now);
+ expect(verifySsoLoginIntent(value, secret, now)?.returnTo).toBe(
+ "/dashboard",
+ );
+ expect(ssoLoginErrorPath("SsoSessionExpired", returnTo)).toBe(
+ "/login?error=SsoSessionExpired",
+ );
+ });
+
+ it.each([
+ { version: 2 },
+ { organizationId: "" },
+ { workosOrganizationId: "attacker" },
+ { connectionId: "https://attacker.example" },
+ { actorId: undefined },
+ { actorId: 42 },
+ { issuedAt: "now" },
+ { nonce: "" },
+ { returnTo: "//attacker.example" },
+ ])("rejects authenticated malformed claims: %j", (override) => {
+ const payload = {
+ ...context,
+ version: 1,
+ issuedAt: Math.floor(now / 1000),
+ nonce: "a".repeat(32),
+ ...override,
+ };
+ expect(
+ verifySsoLoginIntent(signedPayload(payload), secret, now),
+ ).toBeNull();
+ });
+
+ it("rejects missing and oversized cookies", () => {
+ expect(verifySsoLoginIntent(undefined, secret, now)).toBeNull();
+ expect(verifySsoLoginIntent("a".repeat(2049), secret, now)).toBeNull();
+ expect(verifySsoLoginIntent(signedPayload(null), secret, now)).toBeNull();
+ });
+
+ it("uses a host-only secure HttpOnly cookie on HTTPS", () => {
+ const cookie = ssoIntentCookie(true);
+ expect(cookie.name).toMatch(/^__Host-/);
+ expect(cookie.options).toEqual({
+ httpOnly: true,
+ secure: true,
+ sameSite: "lax",
+ path: "/",
+ maxAge: 600,
+ });
+ expect(ssoIntentCookie(false).name).not.toMatch(/^__Host-/);
+ });
+});
diff --git a/apps/web/__tests__/unit/stripe-subscriptions.test.ts b/apps/web/__tests__/unit/stripe-subscriptions.test.ts
new file mode 100644
index 000000000..9c19958a8
--- /dev/null
+++ b/apps/web/__tests__/unit/stripe-subscriptions.test.ts
@@ -0,0 +1,115 @@
+import {
+ hasSsoAccess,
+ isProSubscription,
+ isSsoPrice,
+ isSsoSubscription,
+ STRIPE_SAML_SSO_LEGACY_PRICE_ID,
+ STRIPE_SAML_SSO_PRICE_ID,
+ STRIPE_SAML_SSO_PRODUCT_ID,
+ STRIPE_SIGNED_BAA_PRICE_IDS,
+} from "@cap/utils";
+import { describe, expect, it } from "vitest";
+
+describe("Stripe subscription classification", () => {
+ it.each([STRIPE_SAML_SSO_PRICE_ID, STRIPE_SAML_SSO_LEGACY_PRICE_ID])(
+ "recognizes paid SSO price %s without metadata",
+ (priceId) => {
+ const subscription = { items: { data: [{ price: { id: priceId } }] } };
+ expect(isSsoPrice(priceId)).toBe(true);
+ expect(isSsoSubscription(subscription)).toBe(true);
+ expect(isProSubscription(subscription)).toBe(false);
+ },
+ );
+
+ it.each([STRIPE_SAML_SSO_PRODUCT_ID, { id: STRIPE_SAML_SSO_PRODUCT_ID }])(
+ "isolates SSO product subscriptions with an unrecognized price",
+ (product) => {
+ const subscription = {
+ items: { data: [{ price: { id: "price_other_sso", product } }] },
+ };
+ expect(isSsoSubscription(subscription)).toBe(true);
+ expect(isSsoPrice("price_other_sso")).toBe(false);
+ expect(isProSubscription(subscription)).toBe(false);
+ },
+ );
+
+ it("routes metadata-only SSO away from Pro without recognizing its price", () => {
+ const subscription = {
+ metadata: { type: "saml_sso" },
+ items: { data: [{ price: { id: "price_unknown" } }] },
+ };
+ expect(isSsoSubscription(subscription)).toBe(true);
+ expect(isSsoPrice("price_unknown")).toBe(false);
+ expect(isProSubscription(subscription)).toBe(false);
+ });
+
+ it("excludes both price-only and metadata-only BAA subscriptions", () => {
+ expect(isProSubscription({ metadata: { type: "signed_baa" } })).toBe(false);
+ for (const priceId of Object.values(STRIPE_SIGNED_BAA_PRICE_IDS)) {
+ expect(
+ isProSubscription({ items: { data: [{ price: { id: priceId } }] } }),
+ ).toBe(false);
+ }
+ });
+
+ it("preserves historical Pro prices", () => {
+ const subscription = {
+ items: { data: [{ price: { id: "price_legacy_pro" } }] },
+ };
+ expect(isSsoSubscription(subscription)).toBe(false);
+ expect(isProSubscription(subscription)).toBe(true);
+ expect(isSsoPrice(undefined)).toBe(false);
+ });
+});
+
+describe("paid-through SSO entitlement", () => {
+ const paidThrough = new Date("2026-09-01T00:00:00Z");
+
+ it("keeps active access only during the confirmed paid period", () => {
+ expect(
+ hasSsoAccess(
+ { status: "active", paidThrough },
+ new Date("2026-08-31T23:59:59Z"),
+ ),
+ ).toBe(true);
+ expect(hasSsoAccess({ status: "active", paidThrough }, paidThrough)).toBe(
+ false,
+ );
+ });
+
+ it("grants a bounded seven-day grace only after a paid period", () => {
+ expect(
+ hasSsoAccess(
+ { status: "past_due", paidThrough },
+ new Date("2026-09-07T23:59:59Z"),
+ ),
+ ).toBe(true);
+ expect(
+ hasSsoAccess(
+ { status: "past_due", paidThrough },
+ new Date("2026-09-08T00:00:00Z"),
+ ),
+ ).toBe(false);
+ expect(hasSsoAccess({ status: "past_due", paidThrough: null })).toBe(false);
+ });
+
+ it.each([
+ "trialing",
+ "canceled",
+ "unpaid",
+ "incomplete",
+ "incomplete_expired",
+ ])("denies %s even with a future paid-through date", (status) => {
+ expect(
+ hasSsoAccess({ status, paidThrough }, new Date("2026-08-31T00:00:00Z")),
+ ).toBe(false);
+ });
+
+ it("fails closed for missing or invalid paid-through data", () => {
+ expect(hasSsoAccess(null)).toBe(false);
+ expect(hasSsoAccess({ status: "active", paidThrough: null })).toBe(false);
+ expect(
+ hasSsoAccess({ status: "active", paidThrough: new Date("invalid") }),
+ ).toBe(false);
+ });
+});
diff --git a/packages/database/auth/sso-state.ts b/packages/database/auth/sso-state.ts
new file mode 100644
index 000000000..de636e255
--- /dev/null
+++ b/packages/database/auth/sso-state.ts
@@ -0,0 +1,143 @@
+import { createHmac, randomBytes, timingSafeEqual } from "node:crypto";
+
+export const SSO_INTENT_MAX_AGE = 10 * 60;
+
+export type SsoLoginIntent = {
+ version: 1;
+ organizationId: string;
+ workosOrganizationId: string;
+ connectionId: string;
+ actorId: string | null;
+ returnTo?: string;
+ issuedAt: number;
+ nonce: string;
+};
+
+function isSafeReturnPath(value: unknown): value is string {
+ if (
+ typeof value !== "string" ||
+ value.length > 1024 ||
+ !value.startsWith("/") ||
+ value.startsWith("//") ||
+ value.includes("\\") ||
+ Array.from(value).some((character) => {
+ const code = character.charCodeAt(0);
+ return code < 32 || code === 127;
+ })
+ )
+ return false;
+ try {
+ const url = new URL(value, "https://sso.invalid");
+ return (
+ url.origin === "https://sso.invalid" && !url.pathname.startsWith("//")
+ );
+ } catch {
+ return false;
+ }
+}
+
+export function ssoLoginErrorPath(
+ error: "SsoSessionExpired" | "SsoSignInFailed",
+ returnTo?: string,
+) {
+ const query = new URLSearchParams({ error });
+ if (isSafeReturnPath(returnTo) && returnTo !== "/dashboard")
+ query.set("next", returnTo);
+ return `/login?${query}`;
+}
+
+export function ssoIntentCookie(secure: boolean) {
+ return {
+ name: secure ? "__Host-cap-sso-intent" : "cap-sso-intent",
+ options: {
+ httpOnly: true,
+ secure,
+ sameSite: "lax" as const,
+ path: "/",
+ maxAge: SSO_INTENT_MAX_AGE,
+ },
+ };
+}
+
+export function createSsoLoginIntent(
+ input: Pick<
+ SsoLoginIntent,
+ | "organizationId"
+ | "workosOrganizationId"
+ | "connectionId"
+ | "actorId"
+ | "returnTo"
+ >,
+ secret: string,
+ now = Date.now(),
+) {
+ const payload = Buffer.from(
+ JSON.stringify({
+ ...input,
+ returnTo: isSafeReturnPath(input.returnTo)
+ ? input.returnTo
+ : "/dashboard",
+ version: 1,
+ issuedAt: Math.floor(now / 1000),
+ nonce: randomBytes(24).toString("base64url"),
+ } satisfies SsoLoginIntent),
+ ).toString("base64url");
+ const signature = createHmac("sha256", secret)
+ .update(payload)
+ .digest("base64url");
+ return `${payload}.${signature}`;
+}
+
+export function verifySsoLoginIntent(
+ value: string | undefined,
+ secret: string,
+ now = Date.now(),
+): SsoLoginIntent | null {
+ if (!value || value.length > 2048) return null;
+ const [payload, signature, extra] = value.split(".");
+ if (!payload || !signature || extra) return null;
+ const expected = createHmac("sha256", secret)
+ .update(payload)
+ .digest("base64url");
+ const actualBuffer = Buffer.from(signature);
+ const expectedBuffer = Buffer.from(expected);
+ if (
+ actualBuffer.length !== expectedBuffer.length ||
+ !timingSafeEqual(actualBuffer, expectedBuffer)
+ ) {
+ return null;
+ }
+ try {
+ const data: unknown = JSON.parse(
+ Buffer.from(payload, "base64url").toString("utf8"),
+ );
+ if (!data || typeof data !== "object") return null;
+ const intent = data as Partial<SsoLoginIntent>;
+ if (
+ intent.version !== 1 ||
+ typeof intent.organizationId !== "string" ||
+ !intent.organizationId ||
+ intent.organizationId.length > 64 ||
+ typeof intent.workosOrganizationId !== "string" ||
+ !/^org_[a-zA-Z0-9]+$/.test(intent.workosOrganizationId) ||
+ typeof intent.connectionId !== "string" ||
+ !/^conn_[a-zA-Z0-9]+$/.test(intent.connectionId) ||
+ (intent.actorId !== null &&
+ (typeof intent.actorId !== "string" ||
+ !intent.actorId ||
+ intent.actorId.length > 64)) ||
+ (intent.returnTo !== undefined && !isSafeReturnPath(intent.returnTo)) ||
+ typeof intent.issuedAt !== "number" ||
+ !Number.isSafeInteger(intent.issuedAt) ||
+ typeof intent.nonce !== "string" ||
+ !/^[a-zA-Z0-9_-]{32}$/.test(intent.nonce)
+ ) {
+ return null;
+ }
+ const age = Math.floor(now / 1000) - intent.issuedAt;
+ if (age < -30 || age >= SSO_INTENT_MAX_AGE) return null;
+ return intent as SsoLoginIntent;
+ } catch {
+ return null;
+ }
+}
diff --git a/packages/database/auth/sso.ts b/packages/database/auth/sso.ts
new file mode 100644
index 000000000..8ff3a9bc6
--- /dev/null
+++ b/packages/database/auth/sso.ts
@@ -0,0 +1,276 @@
+import { domainToASCII } from "node:url";
+import { serverEnv } from "@cap/env";
+import { hasSsoAccess } from "@cap/utils";
+import { Organisation, User } from "@cap/web-domain";
+import { WorkOS } from "@workos-inc/node";
+import { and, eq, isNull } from "drizzle-orm";
+import { nanoId } from "../helpers.ts";
+import { db } from "../index.ts";
+import {
+ accounts,
+ organizationInvites,
+ organizationMembers,
+ organizationSso,
+ organizations,
+ users,
+} from "../schema.ts";
+import type { SsoLoginIntent } from "./sso-state.ts";
+
+export type ValidatedSsoIdentity = {
+ organizationId: Organisation.OrganisationId;
+ workosOrganizationId: string;
+ connectionId: string;
+ profileId: string;
+ email: string;
+};
+
+export type SsoAuthContext = {
+ intent: SsoLoginIntent | null;
+ actorId: string | null;
+};
+
+export function getWorkOS() {
+ const { WORKOS_API_KEY, WORKOS_CLIENT_ID } = serverEnv();
+ if (!WORKOS_API_KEY || !WORKOS_CLIENT_ID) {
+ throw new Error("SAML SSO is not configured. Please contact Cap support.");
+ }
+ return new WorkOS(WORKOS_API_KEY, {
+ clientId: WORKOS_CLIENT_ID,
+ timeout: 15_000,
+ });
+}
+
+export function normalizeSsoDomain(value: string) {
+ const input = value.trim().toLowerCase();
+ if (!input || input.length > 253 || /[\s/@:#?\\]/.test(input)) return null;
+ const domain = domainToASCII(input);
+ if (
+ !domain ||
+ !domain.includes(".") ||
+ domain
+ .split(".")
+ .some((label) => !/^[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?$/.test(label))
+ ) {
+ return null;
+ }
+ return domain;
+}
+
+export function getSsoEmailDomain(email: string) {
+ const parts = email.trim().split("@");
+ if (parts.length !== 2 || !parts[0] || /\s/.test(parts[0])) return null;
+ return normalizeSsoDomain(parts[1] ?? "");
+}
+
+export async function getRegisteredSsoOrganization(
+ organizationId: Organisation.OrganisationId,
+) {
+ const [record] = await db()
+ .select({ organization: organizations, billing: organizationSso })
+ .from(organizations)
+ .innerJoin(
+ organizationSso,
+ eq(organizationSso.organizationId, organizations.id),
+ )
+ .where(
+ and(
+ eq(organizations.id, organizationId),
+ isNull(organizations.tombstoneAt),
+ ),
+ )
+ .limit(1);
+ if (!record || !hasSsoAccess(record.billing)) {
+ throw new Error("SAML SSO is not available for this organization.");
+ }
+ return record.organization;
+}
+
+export async function validateSsoSignIn(
+ profile: unknown,
+ providerAccountId: string,
+ context: SsoAuthContext | undefined,
+): Promise<ValidatedSsoIdentity> {
+ const intent = context?.intent;
+ if (!intent || intent.actorId !== context?.actorId) {
+ throw new Error("Your SSO sign-in expired. Please start again.");
+ }
+ if (!profile || typeof profile !== "object")
+ throw new Error("Invalid SSO profile.");
+ const raw = profile as Record<string, unknown>;
+ if (
+ typeof raw.id !== "string" ||
+ raw.id !== providerAccountId ||
+ raw.organization_id !== intent.workosOrganizationId ||
+ raw.connection_id !== intent.connectionId ||
+ typeof raw.email !== "string"
+ ) {
+ throw new Error("The SSO identity does not match this organization.");
+ }
+ const email = raw.email.trim().toLowerCase();
+ const domain = getSsoEmailDomain(email);
+ if (!domain || email.length > 255)
+ throw new Error("Invalid SSO email address.");
+ const organizationId = Organisation.OrganisationId.make(
+ intent.organizationId,
+ );
+ const organization = await getRegisteredSsoOrganization(organizationId);
+ if (organization.workosOrganizationId !== intent.workosOrganizationId) {
+ throw new Error("The SSO organization is no longer connected.");
+ }
+ const workos = getWorkOS();
+ const [workosOrganization, connection] = await Promise.all([
+ workos.organizations.getOrganization(intent.workosOrganizationId),
+ workos.sso.getConnection(intent.connectionId),
+ ]);
+ if (
+ workosOrganization.id !== intent.workosOrganizationId ||
+ connection.organizationId !== workosOrganization.id ||
+ connection.id !== intent.connectionId ||
+ connection.state !== "active" ||
+ !workosOrganization.domains.some(
+ (entry) =>
+ entry.state === "verified" &&
+ normalizeSsoDomain(entry.domain) === domain,
+ )
+ ) {
+ throw new Error("Your work email is not verified for this SSO connection.");
+ }
+ const linkedUsers = await db()
+ .selectDistinct({ id: users.id, email: users.email })
+ .from(accounts)
+ .innerJoin(users, eq(accounts.userId, users.id))
+ .where(
+ and(
+ eq(accounts.provider, "workos"),
+ eq(accounts.providerAccountId, raw.id),
+ ),
+ )
+ .limit(2);
+ if (
+ linkedUsers.some(
+ (user) =>
+ user.email.toLowerCase() !== email ||
+ (linkedUsers[0] && user.id !== linkedUsers[0].id),
+ )
+ ) {
+ throw new Error(
+ "This SSO identity is already linked to a different account.",
+ );
+ }
+ if (context.actorId) {
+ const [actor] = await db()
+ .select({ id: users.id, email: users.email })
+ .from(users)
+ .where(eq(users.id, User.UserId.make(context.actorId)))
+ .limit(1);
+ if (
+ !actor ||
+ actor.email.toLowerCase() !== email ||
+ linkedUsers.some((user) => user.id !== actor.id)
+ ) {
+ throw new Error(
+ "Sign out of your current account before using this SSO identity.",
+ );
+ }
+ }
+ return {
+ organizationId,
+ workosOrganizationId: workosOrganization.id,
+ connectionId: connection.id,
+ profileId: raw.id,
+ email,
+ };
+}
+
+export async function provisionSsoMembership(
+ userId: User.UserId,
+ identity: ValidatedSsoIdentity,
+) {
+ await db().transaction(async (tx) => {
+ const [organization] = await tx
+ .select()
+ .from(organizations)
+ .where(eq(organizations.id, identity.organizationId))
+ .for("update");
+ const [billing] = await tx
+ .select()
+ .from(organizationSso)
+ .where(eq(organizationSso.organizationId, identity.organizationId))
+ .for("update");
+ const [user] = await tx
+ .select()
+ .from(users)
+ .where(eq(users.id, userId))
+ .for("update");
+ if (
+ !organization ||
+ organization.tombstoneAt ||
+ organization.workosOrganizationId !== identity.workosOrganizationId ||
+ !hasSsoAccess(billing) ||
+ !user ||
+ user.email.toLowerCase() !== identity.email
+ ) {
+ throw new Error(
+ "The SSO organization or account is no longer available.",
+ );
+ }
+ const linkedAccounts = await tx
+ .selectDistinct({ userId: accounts.userId })
+ .from(accounts)
+ .where(
+ and(
+ eq(accounts.provider, "workos"),
+ eq(accounts.providerAccountId, identity.profileId),
+ ),
+ )
+ .limit(2);
+ if (linkedAccounts.length !== 1 || linkedAccounts[0]?.userId !== userId)
+ throw new Error("The SSO account is not linked to this user.");
+ const [member] = await tx
+ .select({ id: organizationMembers.id })
+ .from(organizationMembers)
+ .where(
+ and(
+ eq(organizationMembers.userId, userId),
+ eq(organizationMembers.organizationId, identity.organizationId),
+ ),
+ )
+ .limit(1);
+ if (!member) {
+ await tx.insert(organizationMembers).values({
+ id: nanoId(),
+ userId,
+ organizationId: identity.organizationId,
+ role: organization.ownerId === userId ? "owner" : "member",
+ hasProSeat: false,
+ });
+ }
+ await tx
+ .update(organizationInvites)
+ .set({ status: "accepted" })
+ .where(
+ and(
+ eq(organizationInvites.organizationId, identity.organizationId),
+ eq(organizationInvites.invitedEmail, identity.email),
+ eq(organizationInvites.status, "pending"),
+ ),
+ );
+ await tx
+ .update(users)
+ .set({
+ activeOrganizationId: identity.organizationId,
+ defaultOrgId: user.defaultOrgId || identity.organizationId,
+ emailVerified: user.emailVerified ?? new Date(),
+ onboarding_completed_at: user.onboarding_completed_at ?? new Date(),
+ onboardingSteps: {
+ ...user.onboardingSteps,
+ welcome: true,
+ organizationSetup: true,
+ customDomain: true,
+ inviteTeam: true,
+ download: true,
+ },
+ })
+ .where(eq(users.id, userId));
+ });
+}
diff --git a/packages/database/migrations/0040_saml_sso.sql b/packages/database/migrations/0040_saml_sso.sql
new file mode 100644
index 000000000..f8eaddc7e
--- /dev/null
+++ b/packages/database/migrations/0040_saml_sso.sql
@@ -0,0 +1,22 @@
+CREATE TABLE `organization_sso` (
+ `organizationId` varchar(15) NOT NULL,
+ `purchasedByUserId` varchar(15) NOT NULL,
+ `stripeCustomerId` varchar(255),
+ `stripeSubscriptionId` varchar(255),
+ `stripePriceId` varchar(255),
+ `status` varchar(32) NOT NULL DEFAULT 'unpaid',
+ `paidThrough` datetime,
+ `currentPeriodEnd` datetime,
+ `cancelAtPeriodEnd` boolean NOT NULL DEFAULT false,
+ `checkoutAttemptId` varchar(36),
+ `checkoutCurrency` varchar(3),
+ `checkoutPriceId` varchar(255),
+ `checkoutSessionId` varchar(255),
+ `checkoutStartedAt` datetime,
+ `createdAt` timestamp NOT NULL DEFAULT (now()),
+ `updatedAt` timestamp NOT NULL DEFAULT (now()) ON UPDATE CURRENT_TIMESTAMP,
+ CONSTRAINT `organization_sso_organizationId` PRIMARY KEY(`organizationId`),
+ CONSTRAINT `sso_stripe_subscription_id_idx` UNIQUE(`stripeSubscriptionId`)
+);
+--> statement-breakpoint
+ALTER TABLE `organizations` ADD CONSTRAINT `workos_organization_id_idx` UNIQUE(`workosOrganizationId`);
\ No newline at end of file
diff --git a/packages/database/migrations/meta/0040_snapshot.json b/packages/database/migrations/meta/0040_snapshot.json
new file mode 100644
index 000000000..59c3f1bdc
--- /dev/null
+++ b/packages/database/migrations/meta/0040_snapshot.json
@@ -0,0 +1,4631 @@
+{
+ "version": "5",
+ "dialect": "mysql",
+ "id": "68599252-324a-4c46-a56d-00ea23f2760a",
+ "prevId": "c95c8755-4ef8-4c51-ad10-5bd19717d269",
+ "tables": {
+ "accounts": {
+ "name": "accounts",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "providerAccountId": {
+ "name": "providerAccountId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "access_token": {
+ "name": "access_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "expires_in": {
+ "name": "expires_in",
+ "type": "int",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "id_token": {
+ "name": "id_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "refresh_token": {
+ "name": "refresh_token",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "refresh_token_expires_in": {
+ "name": "refresh_token_expires_in",
+ "type": "int",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "scope": {
+ "name": "scope",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "token_type": {
+ "name": "token_type",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ },
+ "tempColumn": {
+ "name": "tempColumn",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "user_id_idx": {
+ "name": "user_id_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ },
+ "provider_account_id_idx": {
+ "name": "provider_account_id_idx",
+ "columns": [
+ "providerAccountId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "accounts_id": {
+ "name": "accounts_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "agent_api_authorization_codes": {
+ "name": "agent_api_authorization_codes",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "codeHash": {
+ "name": "codeHash",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "codeChallenge": {
+ "name": "codeChallenge",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "redirectUri": {
+ "name": "redirectUri",
+ "type": "varchar(512)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expiresAt": {
+ "name": "expiresAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "consumedAt": {
+ "name": "consumedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "code_hash_idx": {
+ "name": "code_hash_idx",
+ "columns": [
+ "codeHash"
+ ],
+ "isUnique": true
+ },
+ "expires_at_idx": {
+ "name": "expires_at_idx",
+ "columns": [
+ "expiresAt"
+ ],
+ "isUnique": false
+ },
+ "user_created_at_idx": {
+ "name": "user_created_at_idx",
+ "columns": [
+ "userId",
+ "createdAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "agent_api_authorization_codes_id": {
+ "name": "agent_api_authorization_codes_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "agent_api_idempotency": {
+ "name": "agent_api_idempotency",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "operation": {
+ "name": "operation",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "keyHash": {
+ "name": "keyHash",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "requestHash": {
+ "name": "requestHash",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "state": {
+ "name": "state",
+ "type": "varchar(16)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'pending'"
+ },
+ "statusCode": {
+ "name": "statusCode",
+ "type": "int",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "response": {
+ "name": "response",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "expiresAt": {
+ "name": "expiresAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "user_operation_key_idx": {
+ "name": "user_operation_key_idx",
+ "columns": [
+ "userId",
+ "operation",
+ "keyHash"
+ ],
+ "isUnique": true
+ },
+ "expires_at_idx": {
+ "name": "expires_at_idx",
+ "columns": [
+ "expiresAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "agent_api_idempotency_id": {
+ "name": "agent_api_idempotency_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "agent_api_keys": {
+ "name": "agent_api_keys",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "tokenHash": {
+ "name": "tokenHash",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(100)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'Cap CLI'"
+ },
+ "scopes": {
+ "name": "scopes",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expiresAt": {
+ "name": "expiresAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "revokedAt": {
+ "name": "revokedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "lastUsedAt": {
+ "name": "lastUsedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "token_hash_idx": {
+ "name": "token_hash_idx",
+ "columns": [
+ "tokenHash"
+ ],
+ "isUnique": true
+ },
+ "user_created_at_idx": {
+ "name": "user_created_at_idx",
+ "columns": [
+ "userId",
+ "createdAt"
+ ],
+ "isUnique": false
+ },
+ "expires_at_idx": {
+ "name": "expires_at_idx",
+ "columns": [
+ "expiresAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "agent_api_keys_id": {
+ "name": "agent_api_keys_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "agent_api_operations": {
+ "name": "agent_api_operations",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "kind": {
+ "name": "kind",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "resourceId": {
+ "name": "resourceId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "resultResourceId": {
+ "name": "resultResourceId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "state": {
+ "name": "state",
+ "type": "varchar(16)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'queued'"
+ },
+ "payload": {
+ "name": "payload",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "result": {
+ "name": "result",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "errorCode": {
+ "name": "errorCode",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "errorMessage": {
+ "name": "errorMessage",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ },
+ "completedAt": {
+ "name": "completedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "user_created_at_idx": {
+ "name": "user_created_at_idx",
+ "columns": [
+ "userId",
+ "createdAt"
+ ],
+ "isUnique": false
+ },
+ "state_updated_at_idx": {
+ "name": "state_updated_at_idx",
+ "columns": [
+ "state",
+ "updatedAt"
+ ],
+ "isUnique": false
+ },
+ "resource_id_idx": {
+ "name": "resource_id_idx",
+ "columns": [
+ "resourceId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "agent_api_operations_id": {
+ "name": "agent_api_operations_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "auth_api_keys": {
+ "name": "auth_api_keys",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(36)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "source": {
+ "name": "source",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'unknown'"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "user_id_created_at_idx": {
+ "name": "user_id_created_at_idx",
+ "columns": [
+ "userId",
+ "createdAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "auth_api_keys_id": {
+ "name": "auth_api_keys_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "comments": {
+ "name": "comments",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "varchar(6)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "timestamp": {
+ "name": "timestamp",
+ "type": "float",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "authorId": {
+ "name": "authorId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "videoId": {
+ "name": "videoId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ },
+ "parentCommentId": {
+ "name": "parentCommentId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "mediaKey": {
+ "name": "mediaKey",
+ "type": "varchar(512)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "mediaDuration": {
+ "name": "mediaDuration",
+ "type": "float",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "mediaMeta": {
+ "name": "mediaMeta",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "video_type_created_idx": {
+ "name": "video_type_created_idx",
+ "columns": [
+ "videoId",
+ "type",
+ "createdAt",
+ "id"
+ ],
+ "isUnique": false
+ },
+ "author_id_idx": {
+ "name": "author_id_idx",
+ "columns": [
+ "authorId"
+ ],
+ "isUnique": false
+ },
+ "parent_comment_id_idx": {
+ "name": "parent_comment_id_idx",
+ "columns": [
+ "parentCommentId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "comments_id": {
+ "name": "comments_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "developer_api_keys": {
+ "name": "developer_api_keys",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "appId": {
+ "name": "appId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "keyType": {
+ "name": "keyType",
+ "type": "varchar(8)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "keyPrefix": {
+ "name": "keyPrefix",
+ "type": "varchar(12)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "keyHash": {
+ "name": "keyHash",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "encryptedKey": {
+ "name": "encryptedKey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "lastUsedAt": {
+ "name": "lastUsedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "revokedAt": {
+ "name": "revokedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "key_hash_idx": {
+ "name": "key_hash_idx",
+ "columns": [
+ "keyHash"
+ ],
+ "isUnique": true
+ },
+ "app_key_type_idx": {
+ "name": "app_key_type_idx",
+ "columns": [
+ "appId",
+ "keyType"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "developer_api_keys_appId_developer_apps_id_fk": {
+ "name": "developer_api_keys_appId_developer_apps_id_fk",
+ "tableFrom": "developer_api_keys",
+ "tableTo": "developer_apps",
+ "columnsFrom": [
+ "appId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "developer_api_keys_id": {
+ "name": "developer_api_keys_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "developer_app_domains": {
+ "name": "developer_app_domains",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "appId": {
+ "name": "appId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "domain": {
+ "name": "domain",
+ "type": "varchar(253)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "developer_app_domains_appId_developer_apps_id_fk": {
+ "name": "developer_app_domains_appId_developer_apps_id_fk",
+ "tableFrom": "developer_app_domains",
+ "tableTo": "developer_apps",
+ "columnsFrom": [
+ "appId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "developer_app_domains_id": {
+ "name": "developer_app_domains_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {
+ "app_domain_unique": {
+ "name": "app_domain_unique",
+ "columns": [
+ "appId",
+ "domain"
+ ]
+ }
+ },
+ "checkConstraint": {}
+ },
+ "developer_apps": {
+ "name": "developer_apps",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "environment": {
+ "name": "environment",
+ "type": "varchar(16)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "logoUrl": {
+ "name": "logoUrl",
+ "type": "varchar(1024)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "deletedAt": {
+ "name": "deletedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "owner_deleted_idx": {
+ "name": "owner_deleted_idx",
+ "columns": [
+ "ownerId",
+ "deletedAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "developer_apps_id": {
+ "name": "developer_apps_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "developer_credit_accounts": {
+ "name": "developer_credit_accounts",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "appId": {
+ "name": "appId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "balanceMicroCredits": {
+ "name": "balanceMicroCredits",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "stripeCustomerId": {
+ "name": "stripeCustomerId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "stripePaymentMethodId": {
+ "name": "stripePaymentMethodId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "autoTopUpEnabled": {
+ "name": "autoTopUpEnabled",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "autoTopUpThresholdMicroCredits": {
+ "name": "autoTopUpThresholdMicroCredits",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "autoTopUpAmountCents": {
+ "name": "autoTopUpAmountCents",
+ "type": "int",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "app_id_unique": {
+ "name": "app_id_unique",
+ "columns": [
+ "appId"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {
+ "developer_credit_accounts_appId_developer_apps_id_fk": {
+ "name": "developer_credit_accounts_appId_developer_apps_id_fk",
+ "tableFrom": "developer_credit_accounts",
+ "tableTo": "developer_apps",
+ "columnsFrom": [
+ "appId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "developer_credit_accounts_id": {
+ "name": "developer_credit_accounts_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "developer_credit_transactions": {
+ "name": "developer_credit_transactions",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "accountId": {
+ "name": "accountId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "varchar(16)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "amountMicroCredits": {
+ "name": "amountMicroCredits",
+ "type": "bigint",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "balanceAfterMicroCredits": {
+ "name": "balanceAfterMicroCredits",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "referenceId": {
+ "name": "referenceId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "referenceType": {
+ "name": "referenceType",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "account_type_created_idx": {
+ "name": "account_type_created_idx",
+ "columns": [
+ "accountId",
+ "type",
+ "createdAt"
+ ],
+ "isUnique": false
+ },
+ "account_ref_dedup_idx": {
+ "name": "account_ref_dedup_idx",
+ "columns": [
+ "accountId",
+ "referenceId",
+ "referenceType"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "dev_credit_txn_account_fk": {
+ "name": "dev_credit_txn_account_fk",
+ "tableFrom": "developer_credit_transactions",
+ "tableTo": "developer_credit_accounts",
+ "columnsFrom": [
+ "accountId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "developer_credit_transactions_id": {
+ "name": "developer_credit_transactions_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "developer_daily_storage_snapshots": {
+ "name": "developer_daily_storage_snapshots",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "appId": {
+ "name": "appId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "snapshotDate": {
+ "name": "snapshotDate",
+ "type": "varchar(10)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "totalDurationMinutes": {
+ "name": "totalDurationMinutes",
+ "type": "float",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "videoCount": {
+ "name": "videoCount",
+ "type": "int",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "microCreditsCharged": {
+ "name": "microCreditsCharged",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "processedAt": {
+ "name": "processedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "developer_daily_storage_snapshots_appId_developer_apps_id_fk": {
+ "name": "developer_daily_storage_snapshots_appId_developer_apps_id_fk",
+ "tableFrom": "developer_daily_storage_snapshots",
+ "tableTo": "developer_apps",
+ "columnsFrom": [
+ "appId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "developer_daily_storage_snapshots_id": {
+ "name": "developer_daily_storage_snapshots_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {
+ "app_date_unique": {
+ "name": "app_date_unique",
+ "columns": [
+ "appId",
+ "snapshotDate"
+ ]
+ }
+ },
+ "checkConstraint": {}
+ },
+ "developer_videos": {
+ "name": "developer_videos",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "appId": {
+ "name": "appId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "externalUserId": {
+ "name": "externalUserId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'Untitled'"
+ },
+ "duration": {
+ "name": "duration",
+ "type": "float",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "width": {
+ "name": "width",
+ "type": "int",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "height": {
+ "name": "height",
+ "type": "int",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "fps": {
+ "name": "fps",
+ "type": "int",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "s3Key": {
+ "name": "s3Key",
+ "type": "varchar(512)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "transcriptionStatus": {
+ "name": "transcriptionStatus",
+ "type": "varchar(16)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "deletedAt": {
+ "name": "deletedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "app_created_idx": {
+ "name": "app_created_idx",
+ "columns": [
+ "appId",
+ "createdAt"
+ ],
+ "isUnique": false
+ },
+ "app_user_idx": {
+ "name": "app_user_idx",
+ "columns": [
+ "appId",
+ "externalUserId"
+ ],
+ "isUnique": false
+ },
+ "app_deleted_idx": {
+ "name": "app_deleted_idx",
+ "columns": [
+ "appId",
+ "deletedAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "developer_videos_appId_developer_apps_id_fk": {
+ "name": "developer_videos_appId_developer_apps_id_fk",
+ "tableFrom": "developer_videos",
+ "tableTo": "developer_apps",
+ "columnsFrom": [
+ "appId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "no action",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "developer_videos_id": {
+ "name": "developer_videos_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "folders": {
+ "name": "folders",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "color": {
+ "name": "color",
+ "type": "varchar(16)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'normal'"
+ },
+ "public": {
+ "name": "public",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "settings": {
+ "name": "settings",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "organizationId": {
+ "name": "organizationId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdById": {
+ "name": "createdById",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "parentId": {
+ "name": "parentId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "organization_id_idx": {
+ "name": "organization_id_idx",
+ "columns": [
+ "organizationId"
+ ],
+ "isUnique": false
+ },
+ "created_by_id_idx": {
+ "name": "created_by_id_idx",
+ "columns": [
+ "createdById"
+ ],
+ "isUnique": false
+ },
+ "parent_id_idx": {
+ "name": "parent_id_idx",
+ "columns": [
+ "parentId"
+ ],
+ "isUnique": false
+ },
+ "space_id_idx": {
+ "name": "space_id_idx",
+ "columns": [
+ "spaceId"
+ ],
+ "isUnique": false
+ },
+ "public_parent_id_idx": {
+ "name": "public_parent_id_idx",
+ "columns": [
+ "public",
+ "parentId"
+ ],
+ "isUnique": false
+ },
+ "public_space_parent_id_idx": {
+ "name": "public_space_parent_id_idx",
+ "columns": [
+ "public",
+ "spaceId",
+ "parentId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "folders_id": {
+ "name": "folders_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "imported_videos": {
+ "name": "imported_videos",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "orgId": {
+ "name": "orgId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "source": {
+ "name": "source",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "source_id": {
+ "name": "source_id",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "imported_videos_orgId_source_source_id_pk": {
+ "name": "imported_videos_orgId_source_source_id_pk",
+ "columns": [
+ "orgId",
+ "source",
+ "source_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "integration_installations": {
+ "name": "integration_installations",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "externalId": {
+ "name": "externalId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "displayName": {
+ "name": "displayName",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organizationId": {
+ "name": "organizationId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "installedByUserId": {
+ "name": "installedByUserId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "encryptedCredentials": {
+ "name": "encryptedCredentials",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "provider_external_id_idx": {
+ "name": "provider_external_id_idx",
+ "columns": [
+ "provider",
+ "externalId"
+ ],
+ "isUnique": true
+ },
+ "organization_provider_display_name_idx": {
+ "name": "organization_provider_display_name_idx",
+ "columns": [
+ "organizationId",
+ "provider",
+ "displayName"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "integration_installations_id": {
+ "name": "integration_installations_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "messenger_conversations": {
+ "name": "messenger_conversations",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "agent": {
+ "name": "agent",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "mode": {
+ "name": "mode",
+ "type": "varchar(16)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'agent'"
+ },
+ "userId": {
+ "name": "userId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "anonymousId": {
+ "name": "anonymousId",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "takeoverByUserId": {
+ "name": "takeoverByUserId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "takeoverAt": {
+ "name": "takeoverAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ },
+ "lastMessageAt": {
+ "name": "lastMessageAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "user_last_message_idx": {
+ "name": "user_last_message_idx",
+ "columns": [
+ "userId",
+ "lastMessageAt"
+ ],
+ "isUnique": false
+ },
+ "anonymous_last_message_idx": {
+ "name": "anonymous_last_message_idx",
+ "columns": [
+ "anonymousId",
+ "lastMessageAt"
+ ],
+ "isUnique": false
+ },
+ "mode_last_message_idx": {
+ "name": "mode_last_message_idx",
+ "columns": [
+ "mode",
+ "lastMessageAt"
+ ],
+ "isUnique": false
+ },
+ "updated_at_idx": {
+ "name": "updated_at_idx",
+ "columns": [
+ "updatedAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "messenger_conversations_id": {
+ "name": "messenger_conversations_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "messenger_messages": {
+ "name": "messenger_messages",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "conversationId": {
+ "name": "conversationId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "varchar(16)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "content": {
+ "name": "content",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "anonymousId": {
+ "name": "anonymousId",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "conversation_created_at_idx": {
+ "name": "conversation_created_at_idx",
+ "columns": [
+ "conversationId",
+ "createdAt"
+ ],
+ "isUnique": false
+ },
+ "role_created_at_idx": {
+ "name": "role_created_at_idx",
+ "columns": [
+ "role",
+ "createdAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "messenger_messages_conversationId_messenger_conversations_id_fk": {
+ "name": "messenger_messages_conversationId_messenger_conversations_id_fk",
+ "tableFrom": "messenger_messages",
+ "tableTo": "messenger_conversations",
+ "columnsFrom": [
+ "conversationId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "messenger_messages_id": {
+ "name": "messenger_messages_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "messenger_support_emails": {
+ "name": "messenger_support_emails",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "conversationId": {
+ "name": "conversationId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userEmail": {
+ "name": "userEmail",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "subject": {
+ "name": "subject",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "message": {
+ "name": "message",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "support_email_user_created_at_idx": {
+ "name": "support_email_user_created_at_idx",
+ "columns": [
+ "userId",
+ "createdAt"
+ ],
+ "isUnique": false
+ },
+ "support_email_conversation_created_at_idx": {
+ "name": "support_email_conversation_created_at_idx",
+ "columns": [
+ "conversationId",
+ "createdAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "support_email_conversation_fk": {
+ "name": "support_email_conversation_fk",
+ "tableFrom": "messenger_support_emails",
+ "tableTo": "messenger_conversations",
+ "columnsFrom": [
+ "conversationId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "messenger_support_emails_id": {
+ "name": "messenger_support_emails_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "notifications": {
+ "name": "notifications",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "orgId": {
+ "name": "orgId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "recipientId": {
+ "name": "recipientId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "type": {
+ "name": "type",
+ "type": "varchar(16)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "data": {
+ "name": "data",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "videoId": {
+ "name": "videoId",
+ "type": "varchar(50)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "dedupKey": {
+ "name": "dedupKey",
+ "type": "varchar(128)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "readAt": {
+ "name": "readAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "org_id_idx": {
+ "name": "org_id_idx",
+ "columns": [
+ "orgId"
+ ],
+ "isUnique": false
+ },
+ "type_idx": {
+ "name": "type_idx",
+ "columns": [
+ "type"
+ ],
+ "isUnique": false
+ },
+ "read_at_idx": {
+ "name": "read_at_idx",
+ "columns": [
+ "readAt"
+ ],
+ "isUnique": false
+ },
+ "created_at_idx": {
+ "name": "created_at_idx",
+ "columns": [
+ "createdAt"
+ ],
+ "isUnique": false
+ },
+ "recipient_read_idx": {
+ "name": "recipient_read_idx",
+ "columns": [
+ "recipientId",
+ "readAt"
+ ],
+ "isUnique": false
+ },
+ "recipient_created_idx": {
+ "name": "recipient_created_idx",
+ "columns": [
+ "recipientId",
+ "createdAt"
+ ],
+ "isUnique": false
+ },
+ "dedup_key_idx": {
+ "name": "dedup_key_idx",
+ "columns": [
+ "dedupKey"
+ ],
+ "isUnique": true
+ },
+ "type_recipient_created_idx": {
+ "name": "type_recipient_created_idx",
+ "columns": [
+ "type",
+ "recipientId",
+ "createdAt"
+ ],
+ "isUnique": false
+ },
+ "type_recipient_video_created_idx": {
+ "name": "type_recipient_video_created_idx",
+ "columns": [
+ "type",
+ "recipientId",
+ "videoId",
+ "createdAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "notifications_id": {
+ "name": "notifications_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "organization_invites": {
+ "name": "organization_invites",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organizationId": {
+ "name": "organizationId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "invitedEmail": {
+ "name": "invitedEmail",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "invitedByUserId": {
+ "name": "invitedByUserId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'pending'"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ },
+ "expiresAt": {
+ "name": "expiresAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "organization_id_idx": {
+ "name": "organization_id_idx",
+ "columns": [
+ "organizationId"
+ ],
+ "isUnique": false
+ },
+ "invited_email_idx": {
+ "name": "invited_email_idx",
+ "columns": [
+ "invitedEmail"
+ ],
+ "isUnique": false
+ },
+ "invited_by_user_id_idx": {
+ "name": "invited_by_user_id_idx",
+ "columns": [
+ "invitedByUserId"
+ ],
+ "isUnique": false
+ },
+ "status_idx": {
+ "name": "status_idx",
+ "columns": [
+ "status"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "organization_invites_id": {
+ "name": "organization_invites_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "organization_members": {
+ "name": "organization_members",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organizationId": {
+ "name": "organizationId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "hasProSeat": {
+ "name": "hasProSeat",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "organization_id_idx": {
+ "name": "organization_id_idx",
+ "columns": [
+ "organizationId"
+ ],
+ "isUnique": false
+ },
+ "user_id_organization_id_idx": {
+ "name": "user_id_organization_id_idx",
+ "columns": [
+ "userId",
+ "organizationId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "organization_members_id": {
+ "name": "organization_members_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "organization_sso": {
+ "name": "organization_sso",
+ "columns": {
+ "organizationId": {
+ "name": "organizationId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "purchasedByUserId": {
+ "name": "purchasedByUserId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "stripeCustomerId": {
+ "name": "stripeCustomerId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "stripeSubscriptionId": {
+ "name": "stripeSubscriptionId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "stripePriceId": {
+ "name": "stripePriceId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'unpaid'"
+ },
+ "paidThrough": {
+ "name": "paidThrough",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "currentPeriodEnd": {
+ "name": "currentPeriodEnd",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "cancelAtPeriodEnd": {
+ "name": "cancelAtPeriodEnd",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "checkoutAttemptId": {
+ "name": "checkoutAttemptId",
+ "type": "varchar(36)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "checkoutCurrency": {
+ "name": "checkoutCurrency",
+ "type": "varchar(3)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "checkoutPriceId": {
+ "name": "checkoutPriceId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "checkoutSessionId": {
+ "name": "checkoutSessionId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "checkoutStartedAt": {
+ "name": "checkoutStartedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "sso_stripe_subscription_id_idx": {
+ "name": "sso_stripe_subscription_id_idx",
+ "columns": [
+ "stripeSubscriptionId"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "organization_sso_organizationId": {
+ "name": "organization_sso_organizationId",
+ "columns": [
+ "organizationId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "organizations": {
+ "name": "organizations",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "tombstoneAt": {
+ "name": "tombstoneAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "allowedEmailDomain": {
+ "name": "allowedEmailDomain",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "customDomain": {
+ "name": "customDomain",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "domainVerified": {
+ "name": "domainVerified",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "settings": {
+ "name": "settings",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "iconUrl": {
+ "name": "iconUrl",
+ "type": "varchar(1024)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "shareableLinkIconUrl": {
+ "name": "shareableLinkIconUrl",
+ "type": "varchar(1024)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ },
+ "workosOrganizationId": {
+ "name": "workosOrganizationId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "workosConnectionId": {
+ "name": "workosConnectionId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "owner_id_tombstone_idx": {
+ "name": "owner_id_tombstone_idx",
+ "columns": [
+ "ownerId",
+ "tombstoneAt"
+ ],
+ "isUnique": false
+ },
+ "custom_domain_idx": {
+ "name": "custom_domain_idx",
+ "columns": [
+ "customDomain"
+ ],
+ "isUnique": false
+ },
+ "workos_organization_id_idx": {
+ "name": "workos_organization_id_idx",
+ "columns": [
+ "workosOrganizationId"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "organizations_id": {
+ "name": "organizations_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "s3_buckets": {
+ "name": "s3_buckets",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organizationId": {
+ "name": "organizationId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "region": {
+ "name": "region",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "endpoint": {
+ "name": "endpoint",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "bucketName": {
+ "name": "bucketName",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "accessKeyId": {
+ "name": "accessKeyId",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "secretAccessKey": {
+ "name": "secretAccessKey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "('aws')"
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "owner_organization_idx": {
+ "name": "owner_organization_idx",
+ "columns": [
+ "ownerId",
+ "organizationId"
+ ],
+ "isUnique": false
+ },
+ "organization_id_idx": {
+ "name": "organization_id_idx",
+ "columns": [
+ "organizationId"
+ ],
+ "isUnique": false
+ },
+ "organization_active_idx": {
+ "name": "organization_active_idx",
+ "columns": [
+ "organizationId",
+ "active",
+ "updatedAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "s3_buckets_id": {
+ "name": "s3_buckets_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "sessions": {
+ "name": "sessions",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "sessionToken": {
+ "name": "sessionToken",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires": {
+ "name": "expires",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "session_token_idx": {
+ "name": "session_token_idx",
+ "columns": [
+ "sessionToken"
+ ],
+ "isUnique": true
+ },
+ "user_id_idx": {
+ "name": "user_id_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "sessions_id": {
+ "name": "sessions_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "shared_videos": {
+ "name": "shared_videos",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "videoId": {
+ "name": "videoId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "folderId": {
+ "name": "folderId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "organizationId": {
+ "name": "organizationId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "sharedByUserId": {
+ "name": "sharedByUserId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "sharedAt": {
+ "name": "sharedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "folder_id_idx": {
+ "name": "folder_id_idx",
+ "columns": [
+ "folderId"
+ ],
+ "isUnique": false
+ },
+ "organization_id_idx": {
+ "name": "organization_id_idx",
+ "columns": [
+ "organizationId"
+ ],
+ "isUnique": false
+ },
+ "shared_by_user_id_idx": {
+ "name": "shared_by_user_id_idx",
+ "columns": [
+ "sharedByUserId"
+ ],
+ "isUnique": false
+ },
+ "video_id_organization_id_idx": {
+ "name": "video_id_organization_id_idx",
+ "columns": [
+ "videoId",
+ "organizationId"
+ ],
+ "isUnique": false
+ },
+ "video_id_folder_id_idx": {
+ "name": "video_id_folder_id_idx",
+ "columns": [
+ "videoId",
+ "folderId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "shared_videos_id": {
+ "name": "shared_videos_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "signed_baas": {
+ "name": "signed_baas",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organizationId": {
+ "name": "organizationId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'pending'"
+ },
+ "stripeSubscriptionId": {
+ "name": "stripeSubscriptionId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "entityName": {
+ "name": "entityName",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "entityType": {
+ "name": "entityType",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "entityAddress": {
+ "name": "entityAddress",
+ "type": "varchar(500)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "signerName": {
+ "name": "signerName",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "signerTitle": {
+ "name": "signerTitle",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "noticesEmail": {
+ "name": "noticesEmail",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "signatureData": {
+ "name": "signatureData",
+ "type": "longtext",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "signedAt": {
+ "name": "signedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "emailSentAt": {
+ "name": "emailSentAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "signed_baa_organization_id_idx": {
+ "name": "signed_baa_organization_id_idx",
+ "columns": [
+ "organizationId"
+ ],
+ "isUnique": true
+ },
+ "signed_baa_stripe_subscription_idx": {
+ "name": "signed_baa_stripe_subscription_idx",
+ "columns": [
+ "stripeSubscriptionId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "signed_baas_id": {
+ "name": "signed_baas_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "space_members": {
+ "name": "space_members",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "userId": {
+ "name": "userId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "role": {
+ "name": "role",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'member'"
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "user_id_idx": {
+ "name": "user_id_idx",
+ "columns": [
+ "userId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "space_members_id": {
+ "name": "space_members_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {
+ "space_id_user_id_unique": {
+ "name": "space_id_user_id_unique",
+ "columns": [
+ "spaceId",
+ "userId"
+ ]
+ }
+ },
+ "checkConstraint": {}
+ },
+ "space_videos": {
+ "name": "space_videos",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "spaceId": {
+ "name": "spaceId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "folderId": {
+ "name": "folderId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "videoId": {
+ "name": "videoId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "addedById": {
+ "name": "addedById",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "addedAt": {
+ "name": "addedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "folder_id_idx": {
+ "name": "folder_id_idx",
+ "columns": [
+ "folderId"
+ ],
+ "isUnique": false
+ },
+ "video_id_idx": {
+ "name": "video_id_idx",
+ "columns": [
+ "videoId"
+ ],
+ "isUnique": false
+ },
+ "added_by_id_idx": {
+ "name": "added_by_id_idx",
+ "columns": [
+ "addedById"
+ ],
+ "isUnique": false
+ },
+ "space_id_video_id_idx": {
+ "name": "space_id_video_id_idx",
+ "columns": [
+ "spaceId",
+ "videoId"
+ ],
+ "isUnique": false
+ },
+ "space_id_folder_id_idx": {
+ "name": "space_id_folder_id_idx",
+ "columns": [
+ "spaceId",
+ "folderId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "space_videos_id": {
+ "name": "space_videos_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "spaces": {
+ "name": "spaces",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "primary": {
+ "name": "primary",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organizationId": {
+ "name": "organizationId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdById": {
+ "name": "createdById",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "iconUrl": {
+ "name": "iconUrl",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "description": {
+ "name": "description",
+ "type": "varchar(1000)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "settings": {
+ "name": "settings",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ },
+ "privacy": {
+ "name": "privacy",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'Private'"
+ },
+ "public": {
+ "name": "public",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ }
+ },
+ "indexes": {
+ "organization_id_idx": {
+ "name": "organization_id_idx",
+ "columns": [
+ "organizationId"
+ ],
+ "isUnique": false
+ },
+ "created_by_id_idx": {
+ "name": "created_by_id_idx",
+ "columns": [
+ "createdById"
+ ],
+ "isUnique": false
+ },
+ "public_organization_id_idx": {
+ "name": "public_organization_id_idx",
+ "columns": [
+ "public",
+ "organizationId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "spaces_id": {
+ "name": "spaces_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "storage_integrations": {
+ "name": "storage_integrations",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "organizationId": {
+ "name": "organizationId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "provider": {
+ "name": "provider",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "displayName": {
+ "name": "displayName",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "status": {
+ "name": "status",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'active'"
+ },
+ "active": {
+ "name": "active",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "encryptedConfig": {
+ "name": "encryptedConfig",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "googleDriveAccessToken": {
+ "name": "googleDriveAccessToken",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "googleDriveAccessTokenExpiresAt": {
+ "name": "googleDriveAccessTokenExpiresAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "googleDriveTokenRefreshLeaseId": {
+ "name": "googleDriveTokenRefreshLeaseId",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "googleDriveTokenRefreshLeaseExpiresAt": {
+ "name": "googleDriveTokenRefreshLeaseExpiresAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "googleDriveStorageQuotaCache": {
+ "name": "googleDriveStorageQuotaCache",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "owner_provider_idx": {
+ "name": "owner_provider_idx",
+ "columns": [
+ "ownerId",
+ "provider"
+ ],
+ "isUnique": false
+ },
+ "owner_active_idx": {
+ "name": "owner_active_idx",
+ "columns": [
+ "ownerId",
+ "active"
+ ],
+ "isUnique": false
+ },
+ "organization_provider_idx": {
+ "name": "organization_provider_idx",
+ "columns": [
+ "organizationId",
+ "provider"
+ ],
+ "isUnique": false
+ },
+ "organization_active_idx": {
+ "name": "organization_active_idx",
+ "columns": [
+ "organizationId",
+ "active",
+ "status"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "storage_integrations_id": {
+ "name": "storage_integrations_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "storage_objects": {
+ "name": "storage_objects",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "integrationId": {
+ "name": "integrationId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "videoId": {
+ "name": "videoId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "objectKey": {
+ "name": "objectKey",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "objectKeyHash": {
+ "name": "objectKeyHash",
+ "type": "varchar(64)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "providerObjectId": {
+ "name": "providerObjectId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "uploadSessionUrl": {
+ "name": "uploadSessionUrl",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "uploadStatus": {
+ "name": "uploadStatus",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'pending'"
+ },
+ "contentType": {
+ "name": "contentType",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "contentLength": {
+ "name": "contentLength",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ }
+ },
+ "indexes": {
+ "integration_key_hash_idx": {
+ "name": "integration_key_hash_idx",
+ "columns": [
+ "integrationId",
+ "objectKeyHash"
+ ],
+ "isUnique": true
+ },
+ "integration_status_idx": {
+ "name": "integration_status_idx",
+ "columns": [
+ "integrationId",
+ "uploadStatus"
+ ],
+ "isUnique": false
+ },
+ "video_id_idx": {
+ "name": "video_id_idx",
+ "columns": [
+ "videoId"
+ ],
+ "isUnique": false
+ },
+ "owner_id_idx": {
+ "name": "owner_id_idx",
+ "columns": [
+ "ownerId"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "storage_objects_integrationId_storage_integrations_id_fk": {
+ "name": "storage_objects_integrationId_storage_integrations_id_fk",
+ "tableFrom": "storage_objects",
+ "tableTo": "storage_integrations",
+ "columnsFrom": [
+ "integrationId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "storage_objects_id": {
+ "name": "storage_objects_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "users": {
+ "name": "users",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "lastName": {
+ "name": "lastName",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "email": {
+ "name": "email",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "emailVerified": {
+ "name": "emailVerified",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "image": {
+ "name": "image",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "stripeCustomerId": {
+ "name": "stripeCustomerId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "stripeSubscriptionId": {
+ "name": "stripeSubscriptionId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "thirdPartyStripeSubscriptionId": {
+ "name": "thirdPartyStripeSubscriptionId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "stripeSubscriptionStatus": {
+ "name": "stripeSubscriptionStatus",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "stripeSubscriptionPriceId": {
+ "name": "stripeSubscriptionPriceId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "preferences": {
+ "name": "preferences",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "default": "('null')"
+ },
+ "activeOrganizationId": {
+ "name": "activeOrganizationId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ },
+ "onboardingSteps": {
+ "name": "onboardingSteps",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "onboarding_completed_at": {
+ "name": "onboarding_completed_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "customBucket": {
+ "name": "customBucket",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "inviteQuota": {
+ "name": "inviteQuota",
+ "type": "int",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 1
+ },
+ "defaultOrgId": {
+ "name": "defaultOrgId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "authSessionVersion": {
+ "name": "authSessionVersion",
+ "type": "int",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ }
+ },
+ "indexes": {
+ "email_idx": {
+ "name": "email_idx",
+ "columns": [
+ "email"
+ ],
+ "isUnique": true
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "users_id": {
+ "name": "users_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "verification_tokens": {
+ "name": "verification_tokens",
+ "columns": {
+ "identifier": {
+ "name": "identifier",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "token": {
+ "name": "token",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "expires": {
+ "name": "expires",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "created_at": {
+ "name": "created_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "verification_tokens_identifier": {
+ "name": "verification_tokens_identifier",
+ "columns": [
+ "identifier"
+ ]
+ }
+ },
+ "uniqueConstraints": {
+ "verification_tokens_token_unique": {
+ "name": "verification_tokens_token_unique",
+ "columns": [
+ "token"
+ ]
+ }
+ },
+ "checkConstraint": {}
+ },
+ "video_edits": {
+ "name": "video_edits",
+ "columns": {
+ "videoId": {
+ "name": "videoId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "sourceKey": {
+ "name": "sourceKey",
+ "type": "varchar(512)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "editSpec": {
+ "name": "editSpec",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ }
+ },
+ "indexes": {},
+ "foreignKeys": {
+ "video_edits_videoId_videos_id_fk": {
+ "name": "video_edits_videoId_videos_id_fk",
+ "tableFrom": "video_edits",
+ "tableTo": "videos",
+ "columnsFrom": [
+ "videoId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "cascade",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "video_edits_videoId": {
+ "name": "video_edits_videoId",
+ "columns": [
+ "videoId"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "video_uploads": {
+ "name": "video_uploads",
+ "columns": {
+ "video_id": {
+ "name": "video_id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "uploaded": {
+ "name": "uploaded",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "total": {
+ "name": "total",
+ "type": "bigint unsigned",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "started_at": {
+ "name": "started_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "updated_at": {
+ "name": "updated_at",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "mode": {
+ "name": "mode",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "phase": {
+ "name": "phase",
+ "type": "varchar(32)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'uploading'"
+ },
+ "processing_progress": {
+ "name": "processing_progress",
+ "type": "int",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": 0
+ },
+ "processing_message": {
+ "name": "processing_message",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "processing_error": {
+ "name": "processing_error",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "raw_file_key": {
+ "name": "raw_file_key",
+ "type": "varchar(512)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ }
+ },
+ "indexes": {
+ "phase_updated_at_video_id_idx": {
+ "name": "phase_updated_at_video_id_idx",
+ "columns": [
+ "phase",
+ "updated_at",
+ "video_id"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {},
+ "compositePrimaryKeys": {
+ "video_uploads_video_id": {
+ "name": "video_uploads_video_id",
+ "columns": [
+ "video_id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ },
+ "videos": {
+ "name": "videos",
+ "columns": {
+ "id": {
+ "name": "id",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "ownerId": {
+ "name": "ownerId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "orgId": {
+ "name": "orgId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false
+ },
+ "name": {
+ "name": "name",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "'My Video'"
+ },
+ "bucket": {
+ "name": "bucket",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "storageIntegrationId": {
+ "name": "storageIntegrationId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "duration": {
+ "name": "duration",
+ "type": "float",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "width": {
+ "name": "width",
+ "type": "int",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "height": {
+ "name": "height",
+ "type": "int",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "fps": {
+ "name": "fps",
+ "type": "int",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "metadata": {
+ "name": "metadata",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "public": {
+ "name": "public",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": true
+ },
+ "settings": {
+ "name": "settings",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "transcriptionStatus": {
+ "name": "transcriptionStatus",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "source": {
+ "name": "source",
+ "type": "json",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "('{\"type\":\"MediaConvert\"}')"
+ },
+ "folderId": {
+ "name": "folderId",
+ "type": "varchar(15)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "createdAt": {
+ "name": "createdAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": "(now())"
+ },
+ "effectiveCreatedAt": {
+ "name": "effectiveCreatedAt",
+ "type": "datetime",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false,
+ "generated": {
+ "as": "COALESCE(\n STR_TO_DATE(JSON_UNQUOTE(JSON_EXTRACT(`metadata`, '$.customCreatedAt')), '%Y-%m-%dT%H:%i:%s.%fZ'),\n STR_TO_DATE(JSON_UNQUOTE(JSON_EXTRACT(`metadata`, '$.customCreatedAt')), '%Y-%m-%dT%H:%i:%sZ'),\n `createdAt`\n )",
+ "type": "stored"
+ }
+ },
+ "updatedAt": {
+ "name": "updatedAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "onUpdate": true,
+ "default": "(now())"
+ },
+ "password": {
+ "name": "password",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "xStreamInfo": {
+ "name": "xStreamInfo",
+ "type": "text",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "firstViewEmailSentAt": {
+ "name": "firstViewEmailSentAt",
+ "type": "timestamp",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "isScreenshot": {
+ "name": "isScreenshot",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ },
+ "awsRegion": {
+ "name": "awsRegion",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "awsBucket": {
+ "name": "awsBucket",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "videoStartTime": {
+ "name": "videoStartTime",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "audioStartTime": {
+ "name": "audioStartTime",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "jobId": {
+ "name": "jobId",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "jobStatus": {
+ "name": "jobStatus",
+ "type": "varchar(255)",
+ "primaryKey": false,
+ "notNull": false,
+ "autoincrement": false
+ },
+ "skipProcessing": {
+ "name": "skipProcessing",
+ "type": "boolean",
+ "primaryKey": false,
+ "notNull": true,
+ "autoincrement": false,
+ "default": false
+ }
+ },
+ "indexes": {
+ "owner_id_idx": {
+ "name": "owner_id_idx",
+ "columns": [
+ "ownerId"
+ ],
+ "isUnique": false
+ },
+ "is_public_idx": {
+ "name": "is_public_idx",
+ "columns": [
+ "public"
+ ],
+ "isUnique": false
+ },
+ "folder_id_idx": {
+ "name": "folder_id_idx",
+ "columns": [
+ "folderId"
+ ],
+ "isUnique": false
+ },
+ "storage_integration_id_idx": {
+ "name": "storage_integration_id_idx",
+ "columns": [
+ "storageIntegrationId"
+ ],
+ "isUnique": false
+ },
+ "org_owner_folder_idx": {
+ "name": "org_owner_folder_idx",
+ "columns": [
+ "orgId",
+ "ownerId",
+ "folderId"
+ ],
+ "isUnique": false
+ },
+ "org_effective_created_idx": {
+ "name": "org_effective_created_idx",
+ "columns": [
+ "orgId",
+ "effectiveCreatedAt"
+ ],
+ "isUnique": false
+ }
+ },
+ "foreignKeys": {
+ "videos_storageIntegrationId_storage_integrations_id_fk": {
+ "name": "videos_storageIntegrationId_storage_integrations_id_fk",
+ "tableFrom": "videos",
+ "tableTo": "storage_integrations",
+ "columnsFrom": [
+ "storageIntegrationId"
+ ],
+ "columnsTo": [
+ "id"
+ ],
+ "onDelete": "restrict",
+ "onUpdate": "no action"
+ }
+ },
+ "compositePrimaryKeys": {
+ "videos_id": {
+ "name": "videos_id",
+ "columns": [
+ "id"
+ ]
+ }
+ },
+ "uniqueConstraints": {},
+ "checkConstraint": {}
+ }
+ },
+ "views": {},
+ "_meta": {
+ "schemas": {},
+ "tables": {},
+ "columns": {}
+ },
+ "internal": {
+ "tables": {},
+ "indexes": {}
+ }
+}
\ No newline at end of file
diff --git a/packages/database/migrations/meta/_journal.json b/packages/database/migrations/meta/_journal.json
index d5ab96235..191a9aedb 100644
--- a/packages/database/migrations/meta/_journal.json
+++ b/packages/database/migrations/meta/_journal.json
@@ -1,286 +1,293 @@
{
- "version": "5",
- "dialect": "mysql",
- "entries": [
- {
- "idx": 0,
- "version": "5",
- "when": 1743020179593,
- "tag": "0000_brown_sunfire",
- "breakpoints": true
- },
- {
- "idx": 1,
- "version": "5",
- "when": 1749268354138,
- "tag": "0001_white_young_avengers",
- "breakpoints": true
- },
- {
- "idx": 2,
- "version": "5",
- "when": 1750935538683,
- "tag": "0002_dusty_maginty",
- "breakpoints": true
- },
- {
- "idx": 3,
- "version": "5",
- "when": 1761710697286,
- "tag": "0003_thin_gressill",
- "breakpoints": true
- },
- {
- "idx": 4,
- "version": "5",
- "when": 1761711378574,
- "tag": "0004_video-org-id",
- "breakpoints": true
- },
- {
- "idx": 5,
- "version": "5",
- "when": 1761711605408,
- "tag": "0005_video-org-id-required",
- "breakpoints": true
- },
- {
- "idx": 6,
- "version": "5",
- "when": 1762410865419,
- "tag": "0006_hesitant_stone_men",
- "breakpoints": true
- },
- {
- "idx": 7,
- "version": "5",
- "when": 1762428551824,
- "tag": "0007_public_toxin",
- "breakpoints": true
- },
- {
- "idx": 8,
- "version": "5",
- "when": 1762428905323,
- "tag": "0008_fat_ender_wiggin",
- "breakpoints": true
- },
- {
- "idx": 9,
- "version": "5",
- "when": 1768139432782,
- "tag": "0009_easy_ulik",
- "breakpoints": true
- },
- {
- "idx": 10,
- "version": "5",
- "when": 1738505600000,
- "tag": "0010_video_uploads_bigint",
- "breakpoints": true
- },
- {
- "idx": 11,
- "version": "5",
- "when": 1771325011010,
- "tag": "0011_public_inhumans",
- "breakpoints": true
- },
- {
- "idx": 12,
- "version": "5",
- "when": 1772534950328,
- "tag": "0012_lethal_lilith",
- "breakpoints": true
- },
- {
- "idx": 13,
- "version": "5",
- "when": 1772573402457,
- "tag": "0013_faithful_marvex",
- "breakpoints": true
- },
- {
- "idx": 14,
- "version": "5",
- "when": 1772576220593,
- "tag": "0014_modern_triton",
- "breakpoints": true
- },
- {
- "idx": 15,
- "version": "5",
- "when": 1772582468257,
- "tag": "0015_closed_tigra",
- "breakpoints": true
- },
- {
- "idx": 16,
- "version": "5",
- "when": 1772641549840,
- "tag": "0016_bouncy_hellcat",
- "breakpoints": true
- },
- {
- "idx": 17,
- "version": "5",
- "when": 1778099532336,
- "tag": "0017_productive_betty_brant",
- "breakpoints": true
- },
- {
- "idx": 18,
- "version": "5",
- "when": 1778153157657,
- "tag": "0018_loud_mongu",
- "breakpoints": true
- },
- {
- "idx": 19,
- "version": "5",
- "when": 1778154209547,
- "tag": "0019_solid_paibok",
- "breakpoints": true
- },
- {
- "idx": 20,
- "version": "5",
- "when": 1778157016497,
- "tag": "0020_orange_talkback",
- "breakpoints": true
- },
- {
- "idx": 21,
- "version": "5",
- "when": 1778249922872,
- "tag": "0021_glorious_khan",
- "breakpoints": true
- },
- {
- "idx": 22,
- "version": "5",
- "when": 1778252207674,
- "tag": "0022_dazzling_namor",
- "breakpoints": true
- },
- {
- "idx": 23,
- "version": "5",
- "when": 1778434170430,
- "tag": "0023_misty_luckman",
- "breakpoints": true
- },
- {
- "idx": 24,
- "version": "5",
- "when": 1778776694053,
- "tag": "0024_many_speed",
- "breakpoints": true
- },
- {
- "idx": 25,
- "version": "5",
- "when": 1778858762935,
- "tag": "0025_demonic_mother_askani",
- "breakpoints": true
- },
- {
- "idx": 26,
- "version": "5",
- "when": 1779283712737,
- "tag": "0026_pretty_the_professor",
- "breakpoints": true
- },
- {
- "idx": 27,
- "version": "5",
- "when": 1780932760351,
- "tag": "0027_giant_shinko_yamashiro",
- "breakpoints": true
- },
- {
- "idx": 28,
- "version": "5",
- "when": 1780937790068,
- "tag": "0028_nebulous_madame_masque",
- "breakpoints": true
- },
- {
- "idx": 29,
- "version": "5",
- "when": 1780937848351,
- "tag": "0029_blushing_pretty_boy",
- "breakpoints": true
- },
- {
- "idx": 30,
- "version": "5",
- "when": 1780940100362,
- "tag": "0030_add_folder_settings",
- "breakpoints": true
- },
- {
- "idx": 31,
- "version": "5",
- "when": 1781271269353,
- "tag": "0031_add_auth_api_keys_user_created_index",
- "breakpoints": true
- },
- {
- "idx": 32,
- "version": "5",
- "when": 1782850635482,
- "tag": "0032_past_lester",
- "breakpoints": true
- },
- {
- "idx": 33,
- "version": "5",
- "when": 1782853232527,
- "tag": "0033_fluffy_gamora",
- "breakpoints": true
- },
- {
- "idx": 34,
- "version": "5",
- "when": 1782854064505,
- "tag": "0034_fluffy_falcon",
- "breakpoints": true
- },
- {
- "idx": 35,
- "version": "5",
- "when": 1784393810560,
- "tag": "0035_agent_api",
- "breakpoints": true
- },
- {
- "idx": 36,
- "version": "5",
- "when": 1784402487715,
- "tag": "0036_premium_master_chief",
- "breakpoints": true
- },
- {
- "idx": 37,
- "version": "5",
- "when": 1785452585612,
- "tag": "0037_integration_installations",
- "breakpoints": true
- },
- {
- "idx": 38,
- "version": "5",
- "when": 1785892430217,
- "tag": "0038_mean_ozymandias",
- "breakpoints": true
- },
- {
- "idx": 39,
- "version": "5",
- "when": 1787096888361,
- "tag": "0039_magical_vermin",
- "breakpoints": true
- }
- ]
-}
+ "version": "5",
+ "dialect": "mysql",
+ "entries": [
+ {
+ "idx": 0,
+ "version": "5",
+ "when": 1743020179593,
+ "tag": "0000_brown_sunfire",
+ "breakpoints": true
+ },
+ {
+ "idx": 1,
+ "version": "5",
+ "when": 1749268354138,
+ "tag": "0001_white_young_avengers",
+ "breakpoints": true
+ },
+ {
+ "idx": 2,
+ "version": "5",
+ "when": 1750935538683,
+ "tag": "0002_dusty_maginty",
+ "breakpoints": true
+ },
+ {
+ "idx": 3,
+ "version": "5",
+ "when": 1761710697286,
+ "tag": "0003_thin_gressill",
+ "breakpoints": true
+ },
+ {
+ "idx": 4,
+ "version": "5",
+ "when": 1761711378574,
+ "tag": "0004_video-org-id",
+ "breakpoints": true
+ },
+ {
+ "idx": 5,
+ "version": "5",
+ "when": 1761711605408,
+ "tag": "0005_video-org-id-required",
+ "breakpoints": true
+ },
+ {
+ "idx": 6,
+ "version": "5",
+ "when": 1762410865419,
+ "tag": "0006_hesitant_stone_men",
+ "breakpoints": true
+ },
+ {
+ "idx": 7,
+ "version": "5",
+ "when": 1762428551824,
+ "tag": "0007_public_toxin",
+ "breakpoints": true
+ },
+ {
+ "idx": 8,
+ "version": "5",
+ "when": 1762428905323,
+ "tag": "0008_fat_ender_wiggin",
+ "breakpoints": true
+ },
+ {
+ "idx": 9,
+ "version": "5",
+ "when": 1768139432782,
+ "tag": "0009_easy_ulik",
+ "breakpoints": true
+ },
+ {
+ "idx": 10,
+ "version": "5",
+ "when": 1738505600000,
+ "tag": "0010_video_uploads_bigint",
+ "breakpoints": true
+ },
+ {
+ "idx": 11,
+ "version": "5",
+ "when": 1771325011010,
+ "tag": "0011_public_inhumans",
+ "breakpoints": true
+ },
+ {
+ "idx": 12,
+ "version": "5",
+ "when": 1772534950328,
+ "tag": "0012_lethal_lilith",
+ "breakpoints": true
+ },
+ {
+ "idx": 13,
+ "version": "5",
+ "when": 1772573402457,
+ "tag": "0013_faithful_marvex",
+ "breakpoints": true
+ },
+ {
+ "idx": 14,
+ "version": "5",
+ "when": 1772576220593,
+ "tag": "0014_modern_triton",
+ "breakpoints": true
+ },
+ {
+ "idx": 15,
+ "version": "5",
+ "when": 1772582468257,
+ "tag": "0015_closed_tigra",
+ "breakpoints": true
+ },
+ {
+ "idx": 16,
+ "version": "5",
+ "when": 1772641549840,
+ "tag": "0016_bouncy_hellcat",
+ "breakpoints": true
+ },
+ {
+ "idx": 17,
+ "version": "5",
+ "when": 1778099532336,
+ "tag": "0017_productive_betty_brant",
+ "breakpoints": true
+ },
+ {
+ "idx": 18,
+ "version": "5",
+ "when": 1778153157657,
+ "tag": "0018_loud_mongu",
+ "breakpoints": true
+ },
+ {
+ "idx": 19,
+ "version": "5",
+ "when": 1778154209547,
+ "tag": "0019_solid_paibok",
+ "breakpoints": true
+ },
+ {
+ "idx": 20,
+ "version": "5",
+ "when": 1778157016497,
+ "tag": "0020_orange_talkback",
+ "breakpoints": true
+ },
+ {
+ "idx": 21,
+ "version": "5",
+ "when": 1778249922872,
+ "tag": "0021_glorious_khan",
+ "breakpoints": true
+ },
+ {
+ "idx": 22,
+ "version": "5",
+ "when": 1778252207674,
+ "tag": "0022_dazzling_namor",
+ "breakpoints": true
+ },
+ {
+ "idx": 23,
+ "version": "5",
+ "when": 1778434170430,
+ "tag": "0023_misty_luckman",
+ "breakpoints": true
+ },
+ {
+ "idx": 24,
+ "version": "5",
+ "when": 1778776694053,
+ "tag": "0024_many_speed",
+ "breakpoints": true
+ },
+ {
+ "idx": 25,
+ "version": "5",
+ "when": 1778858762935,
+ "tag": "0025_demonic_mother_askani",
+ "breakpoints": true
+ },
+ {
+ "idx": 26,
+ "version": "5",
+ "when": 1779283712737,
+ "tag": "0026_pretty_the_professor",
+ "breakpoints": true
+ },
+ {
+ "idx": 27,
+ "version": "5",
+ "when": 1780932760351,
+ "tag": "0027_giant_shinko_yamashiro",
+ "breakpoints": true
+ },
+ {
+ "idx": 28,
+ "version": "5",
+ "when": 1780937790068,
+ "tag": "0028_nebulous_madame_masque",
+ "breakpoints": true
+ },
+ {
+ "idx": 29,
+ "version": "5",
+ "when": 1780937848351,
+ "tag": "0029_blushing_pretty_boy",
+ "breakpoints": true
+ },
+ {
+ "idx": 30,
+ "version": "5",
+ "when": 1780940100362,
+ "tag": "0030_add_folder_settings",
+ "breakpoints": true
+ },
+ {
+ "idx": 31,
+ "version": "5",
+ "when": 1781271269353,
+ "tag": "0031_add_auth_api_keys_user_created_index",
+ "breakpoints": true
+ },
+ {
+ "idx": 32,
+ "version": "5",
+ "when": 1782850635482,
+ "tag": "0032_past_lester",
+ "breakpoints": true
+ },
+ {
+ "idx": 33,
+ "version": "5",
+ "when": 1782853232527,
+ "tag": "0033_fluffy_gamora",
+ "breakpoints": true
+ },
+ {
+ "idx": 34,
+ "version": "5",
+ "when": 1782854064505,
+ "tag": "0034_fluffy_falcon",
+ "breakpoints": true
+ },
+ {
+ "idx": 35,
+ "version": "5",
+ "when": 1784393810560,
+ "tag": "0035_agent_api",
+ "breakpoints": true
+ },
+ {
+ "idx": 36,
+ "version": "5",
+ "when": 1784402487715,
+ "tag": "0036_premium_master_chief",
+ "breakpoints": true
+ },
+ {
+ "idx": 37,
+ "version": "5",
+ "when": 1785452585612,
+ "tag": "0037_integration_installations",
+ "breakpoints": true
+ },
+ {
+ "idx": 38,
+ "version": "5",
+ "when": 1785892430217,
+ "tag": "0038_mean_ozymandias",
+ "breakpoints": true
+ },
+ {
+ "idx": 39,
+ "version": "5",
+ "when": 1787096888361,
+ "tag": "0039_magical_vermin",
+ "breakpoints": true
+ },
+ {
+ "idx": 40,
+ "version": "5",
+ "when": 1788378518770,
+ "tag": "0040_saml_sso",
+ "breakpoints": true
+ }
+ ]
+}
\ No newline at end of file
diff --git a/packages/database/package.json b/packages/database/package.json
index 7c47305c9..a3decdc35 100644
--- a/packages/database/package.json
+++ b/packages/database/package.json
@@ -26,6 +26,7 @@
"@react-email/components": "^0.1.0",
"@react-email/render": "1.1.2",
"@react-email/tailwind": "^1.0.5",
+ "@workos-inc/node": "^7.34.0",
"drizzle-orm": "0.44.6",
"dub": "^0.64.0",
"effect": "^3.18.4",
@@ -60,6 +61,8 @@
"./auth/auth-options": "./auth/auth-options.ts",
"./auth/domain-utils": "./auth/domain-utils.ts",
"./auth/session": "./auth/session.ts",
+ "./auth/sso": "./auth/sso.ts",
+ "./auth/sso-state": "./auth/sso-state.ts",
"./schema": "./schema.ts",
"./crypto": "./crypto.ts",
"./helpers": "./helpers.ts",
diff --git a/packages/database/schema.ts b/packages/database/schema.ts
index 1510b6d44..c8571a512 100644
--- a/packages/database/schema.ts
+++ b/packages/database/schema.ts
@@ -229,6 +229,41 @@ export const organizations = mysqlTable(
table.tombstoneAt,
),
customDomainIndex: index("custom_domain_idx").on(table.customDomain),
+ workosOrganizationIdIndex: uniqueIndex("workos_organization_id_idx").on(
+ table.workosOrganizationId,
+ ),
+ }),
+);
+
+export const organizationSso = mysqlTable(
+ "organization_sso",
+ {
+ organizationId: nanoId("organizationId")
+ .notNull()
+ .primaryKey()
+ .$type<Organisation.OrganisationId>(),
+ purchasedByUserId: nanoId("purchasedByUserId")
+ .notNull()
+ .$type<User.UserId>(),
+ stripeCustomerId: varchar("stripeCustomerId", { length: 255 }),
+ stripeSubscriptionId: varchar("stripeSubscriptionId", { length: 255 }),
+ stripePriceId: varchar("stripePriceId", { length: 255 }),
+ status: varchar("status", { length: 32 }).notNull().default("unpaid"),
+ paidThrough: datetime("paidThrough"),
+ currentPeriodEnd: datetime("currentPeriodEnd"),
+ cancelAtPeriodEnd: boolean("cancelAtPeriodEnd").notNull().default(false),
+ checkoutAttemptId: varchar("checkoutAttemptId", { length: 36 }),
+ checkoutCurrency: varchar("checkoutCurrency", { length: 3 }),
+ checkoutPriceId: varchar("checkoutPriceId", { length: 255 }),
+ checkoutSessionId: varchar("checkoutSessionId", { length: 255 }),
+ checkoutStartedAt: datetime("checkoutStartedAt"),
+ createdAt: timestamp("createdAt").notNull().defaultNow(),
+ updatedAt: timestamp("updatedAt").notNull().defaultNow().onUpdateNow(),
+ },
+ (table) => ({
+ stripeSubscriptionIdIndex: uniqueIndex("sso_stripe_subscription_id_idx").on(
+ table.stripeSubscriptionId,
+ ),
}),
);
diff --git a/packages/env/server.ts b/packages/env/server.ts
index ecc905f38..324453f0b 100644
--- a/packages/env/server.ts
+++ b/packages/env/server.ts
@@ -139,6 +139,7 @@ function createServerEnv() {
/// Cap Cloud
// These are only needed for Cap Cloud (https://cap.so)
STRIPE_SECRET_KEY: z.string().optional(),
+ STRIPE_SAML_SSO_PRICE_ID: z.string().optional(),
STRIPE_WEBHOOK_SECRET: z.string().optional(),
DISCORD_FEEDBACK_WEBHOOK_URL: z.string().optional(),
DISCORD_LOGS_WEBHOOK_URL: z.string().optional(),
diff --git a/packages/utils/src/constants/plans.ts b/packages/utils/src/constants/plans.ts
index a07fce7e0..92c4ebcdb 100644
--- a/packages/utils/src/constants/plans.ts
+++ b/packages/utils/src/constants/plans.ts
@@ -23,6 +23,10 @@ export const STRIPE_SIGNED_BAA_PRICE_IDS: Record<string, string> = {
export const SIGNED_BAA_PRICE_PER_MONTH = 99;
+export const STRIPE_SAML_SSO_PRICE_ID = "price_1UBJpTFJxA1XpeSsQmAOhibr";
+export const STRIPE_SAML_SSO_LEGACY_PRICE_ID = "price_1UBJQuFJxA1XpeSsnxL2KhP7";
+export const STRIPE_SAML_SSO_PRODUCT_ID = "prod_VBgo5t1scWLUPy";
+
export const userIsPro = (
user?: {
stripeSubscriptionStatus?: string | null;
diff --git a/packages/utils/src/index.ts b/packages/utils/src/index.ts
index dd239b681..995ff8791 100644
--- a/packages/utils/src/index.ts
+++ b/packages/utils/src/index.ts
@@ -2,4 +2,5 @@ export * from "./constants/plans.ts";
export * from "./helpers.ts";
export * from "./lib/dub.ts";
export * from "./lib/stripe/stripe.ts";
+export * from "./lib/stripe/subscriptions.ts";
export * from "./types/database.ts";
diff --git a/packages/utils/src/lib/stripe/subscriptions.ts b/packages/utils/src/lib/stripe/subscriptions.ts
new file mode 100644
index 000000000..4794757c9
--- /dev/null
+++ b/packages/utils/src/lib/stripe/subscriptions.ts
@@ -0,0 +1,66 @@
+import {
+ STRIPE_SAML_SSO_LEGACY_PRICE_ID,
+ STRIPE_SAML_SSO_PRICE_ID,
+ STRIPE_SAML_SSO_PRODUCT_ID,
+ STRIPE_SIGNED_BAA_PRICE_IDS,
+} from "../../constants/plans.ts";
+
+type SubscriptionIdentity = {
+ metadata?: Record<string, string> | null;
+ items?: {
+ data: {
+ price?: {
+ id?: string;
+ product?: string | { id: string } | null;
+ } | null;
+ }[];
+ };
+};
+
+export function isSsoPrice(priceId: string | null | undefined) {
+ return (
+ priceId === STRIPE_SAML_SSO_PRICE_ID ||
+ priceId === STRIPE_SAML_SSO_LEGACY_PRICE_ID
+ );
+}
+
+export function isSsoSubscription(subscription: SubscriptionIdentity) {
+ return (
+ subscription.metadata?.type === "saml_sso" ||
+ subscription.items?.data.some((item) => {
+ const product = item.price?.product;
+ return (
+ isSsoPrice(item.price?.id) ||
+ (typeof product === "string" ? product : product?.id) ===
+ STRIPE_SAML_SSO_PRODUCT_ID
+ );
+ }) === true
+ );
+}
+
+export function isProSubscription(subscription: SubscriptionIdentity) {
+ return (
+ !isSsoSubscription(subscription) &&
+ subscription.metadata?.type !== "signed_baa" &&
+ !subscription.items?.data.some((item) =>
+ Object.values(STRIPE_SIGNED_BAA_PRICE_IDS).some(
+ (priceId) => priceId === item.price?.id,
+ ),
+ )
+ );
+}
+
+export function hasSsoAccess(
+ billing: { status: string; paidThrough: Date | null } | null | undefined,
+ now = new Date(),
+) {
+ if (
+ !billing?.paidThrough ||
+ (billing.status !== "active" && billing.status !== "past_due")
+ )
+ return false;
+
+ const paidThrough = billing.paidThrough.getTime();
+ const grace = billing.status === "past_due" ? 7 * 24 * 60 * 60 * 1000 : 0;
+ return Number.isFinite(paidThrough) && now.getTime() < paidThrough + grace;
+}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 6cc74db42..e82ef3164 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -1242,6 +1242,9 @@ importers:
'@react-email/tailwind':
specifier: ^1.0.5
version: 1.2.2([email protected])
+ '@workos-inc/node':
+ specifier: ^7.34.0
drizzle-orm:
specifier: 0.44.6
version: 0.44.6(@cloudflare/[email protected])(@opentelemetry/[email protected])(@planetscale/[email protected])([email protected])([email protected](@types/[email protected]))