From 036fe25e5574a2b8d95d948fb5bff7aa5eef7716 Mon Sep 17 00:00:00 2001 From: Henry Date: Tue, 7 Oct 2025 21:42:40 +0100 Subject: [PATCH] feat: add type and sourceId columns to board schema --- .../20251007204129_AddBoardTypeAndSourceIdColumns.sql | 5 +++++ packages/db/src/schema/boards.ts | 8 ++++++++ 2 files changed, 13 insertions(+) create mode 100644 packages/db/migrations/20251007204129_AddBoardTypeAndSourceIdColumns.sql diff --git a/packages/db/migrations/20251007204129_AddBoardTypeAndSourceIdColumns.sql b/packages/db/migrations/20251007204129_AddBoardTypeAndSourceIdColumns.sql new file mode 100644 index 00000000..be4a1c9b --- /dev/null +++ b/packages/db/migrations/20251007204129_AddBoardTypeAndSourceIdColumns.sql @@ -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"); \ No newline at end of file diff --git a/packages/db/src/schema/boards.ts b/packages/db/src/schema/boards.ts index c43f32f1..a8720e1f 100644 --- a/packages/db/src/schema/boards.ts +++ b/packages/db/src/schema/boards.ts @@ -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`),