feat: add workspace invite links schema
This commit is contained in:
@@ -0,0 +1,17 @@
|
|||||||
|
CREATE TYPE "public"."invite_link_status" AS ENUM('active', 'inactive');--> statement-breakpoint
|
||||||
|
CREATE TABLE IF NOT EXISTS "workspace_invite_links" (
|
||||||
|
"id" bigserial PRIMARY KEY NOT NULL,
|
||||||
|
"workspaceId" bigint NOT NULL,
|
||||||
|
"code" varchar(12) NOT NULL,
|
||||||
|
"status" "invite_link_status" DEFAULT 'active' NOT NULL,
|
||||||
|
"expiresAt" timestamp,
|
||||||
|
"createdAt" timestamp DEFAULT now() NOT NULL,
|
||||||
|
CONSTRAINT "workspace_invite_links_code_unique" UNIQUE("code")
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
ALTER TABLE "workspace_invite_links" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "workspace_invite_links" ADD CONSTRAINT "workspace_invite_links_workspaceId_workspace_id_fk" FOREIGN KEY ("workspaceId") REFERENCES "public"."workspace"("id") ON DELETE cascade ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
||||||
2709
packages/db/migrations/meta/20250923143130_snapshot.json
Normal file
2709
packages/db/migrations/meta/20250923143130_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -106,6 +106,13 @@
|
|||||||
"when": 1758226671081,
|
"when": 1758226671081,
|
||||||
"tag": "20250918201751_AddPausedMemberStatus",
|
"tag": "20250918201751_AddPausedMemberStatus",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 15,
|
||||||
|
"version": "7",
|
||||||
|
"when": 1758637890146,
|
||||||
|
"tag": "20250923143130_AddWorkspaceInviteLinks",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
28
packages/db/src/schema/workspaceInviteLinks.ts
Normal file
28
packages/db/src/schema/workspaceInviteLinks.ts
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import {
|
||||||
|
bigint,
|
||||||
|
bigserial,
|
||||||
|
pgEnum,
|
||||||
|
pgTable,
|
||||||
|
timestamp,
|
||||||
|
varchar,
|
||||||
|
} from "drizzle-orm/pg-core";
|
||||||
|
|
||||||
|
import { workspaces } from "./workspaces";
|
||||||
|
|
||||||
|
export const inviteLinkStatuses = ["active", "inactive"] as const;
|
||||||
|
export type InviteLinkStatus = (typeof inviteLinkStatuses)[number];
|
||||||
|
export const inviteLinkStatusEnum = pgEnum(
|
||||||
|
"invite_link_status",
|
||||||
|
inviteLinkStatuses,
|
||||||
|
);
|
||||||
|
|
||||||
|
export const workspaceInviteLinks = pgTable("workspace_invite_links", {
|
||||||
|
id: bigserial("id", { mode: "number" }).primaryKey(),
|
||||||
|
workspaceId: bigint("workspaceId", { mode: "number" })
|
||||||
|
.notNull()
|
||||||
|
.references(() => workspaces.id, { onDelete: "cascade" }),
|
||||||
|
code: varchar("code", { length: 12 }).notNull().unique(),
|
||||||
|
status: inviteLinkStatusEnum("status").notNull().default("active"),
|
||||||
|
expiresAt: timestamp("expiresAt"),
|
||||||
|
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||||
|
}).enableRLS();
|
||||||
Reference in New Issue
Block a user