feat: add type and sourceId columns to board schema

This commit is contained in:
Henry
2025-10-07 21:42:40 +01:00
parent 362381f516
commit 036fe25e55
2 changed files with 13 additions and 0 deletions

View File

@@ -0,0 +1,5 @@
CREATE TYPE "public"."board_type" AS ENUM('regular', 'template');--> statement-breakpoint
ALTER TABLE "board" ADD COLUMN "type" "board_type" DEFAULT 'regular' NOT NULL;--> statement-breakpoint
ALTER TABLE "board" ADD COLUMN "sourceBoardId" bigint;--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "board_type_idx" ON "board" USING btree ("type");--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "board_source_idx" ON "board" USING btree ("sourceBoardId");

View File

@@ -25,6 +25,10 @@ export const boardVisibilityEnum = pgEnum(
boardVisibilityStatuses,
);
export const boardTypes = ["regular", "template"] as const;
export type BoardType = (typeof boardTypes)[number];
export const boardTypeEnum = pgEnum("board_type", boardTypes);
export const boards = pgTable(
"board",
{
@@ -49,9 +53,13 @@ export const boards = pgTable(
.notNull()
.references(() => workspaces.id, { onDelete: "cascade" }),
visibility: boardVisibilityEnum("visibility").notNull().default("private"),
type: boardTypeEnum("type").notNull().default("regular"),
sourceBoardId: bigint("sourceBoardId", { mode: "number" }),
},
(table) => [
index("board_visibility_idx").on(table.visibility),
index("board_type_idx").on(table.type),
index("board_source_idx").on(table.sourceBoardId),
uniqueIndex("unique_slug_per_workspace")
.on(table.workspaceId, table.slug)
.where(sql`${table.deletedAt} IS NULL`),