feat: add type and sourceId columns to board schema
This commit is contained in:
@@ -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");
|
||||||
@@ -25,6 +25,10 @@ export const boardVisibilityEnum = pgEnum(
|
|||||||
boardVisibilityStatuses,
|
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(
|
export const boards = pgTable(
|
||||||
"board",
|
"board",
|
||||||
{
|
{
|
||||||
@@ -49,9 +53,13 @@ export const boards = pgTable(
|
|||||||
.notNull()
|
.notNull()
|
||||||
.references(() => workspaces.id, { onDelete: "cascade" }),
|
.references(() => workspaces.id, { onDelete: "cascade" }),
|
||||||
visibility: boardVisibilityEnum("visibility").notNull().default("private"),
|
visibility: boardVisibilityEnum("visibility").notNull().default("private"),
|
||||||
|
type: boardTypeEnum("type").notNull().default("regular"),
|
||||||
|
sourceBoardId: bigint("sourceBoardId", { mode: "number" }),
|
||||||
},
|
},
|
||||||
(table) => [
|
(table) => [
|
||||||
index("board_visibility_idx").on(table.visibility),
|
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")
|
uniqueIndex("unique_slug_per_workspace")
|
||||||
.on(table.workspaceId, table.slug)
|
.on(table.workspaceId, table.slug)
|
||||||
.where(sql`${table.deletedAt} IS NULL`),
|
.where(sql`${table.deletedAt} IS NULL`),
|
||||||
|
|||||||
Reference in New Issue
Block a user