feat: board slugs
This commit is contained in:
@@ -30,6 +30,7 @@ export const getByPublicId = async (
|
||||
`
|
||||
publicId,
|
||||
name,
|
||||
slug,
|
||||
workspace (
|
||||
publicId,
|
||||
members:workspace_members (
|
||||
@@ -151,14 +152,19 @@ export const create = async (
|
||||
|
||||
export const update = async (
|
||||
db: SupabaseClient<Database>,
|
||||
boardInput: { name: string; boardPublicId: string },
|
||||
boardInput: {
|
||||
name: string | undefined;
|
||||
slug: string | undefined;
|
||||
boardPublicId: string;
|
||||
},
|
||||
) => {
|
||||
const { data } = await db
|
||||
.from("board")
|
||||
.update({ name: boardInput.name })
|
||||
.update({ name: boardInput.name, slug: boardInput.slug })
|
||||
.eq("publicId", boardInput.boardPublicId)
|
||||
.select(`publicId, name`)
|
||||
.limit(1)
|
||||
.order("id", { ascending: false })
|
||||
.single();
|
||||
|
||||
return data;
|
||||
|
||||
@@ -123,6 +123,7 @@ export const getBySlugWithBoards = async (
|
||||
slug,
|
||||
boards: board (
|
||||
publicId,
|
||||
slug,
|
||||
name
|
||||
)
|
||||
`,
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
primaryKey,
|
||||
text,
|
||||
timestamp,
|
||||
uniqueIndex,
|
||||
uuid,
|
||||
varchar,
|
||||
} from "drizzle-orm/pg-core";
|
||||
@@ -46,22 +47,35 @@ export const workspacePlanEnum = pgEnum("workspace_plan", [
|
||||
"enterprise",
|
||||
]);
|
||||
|
||||
export const boards = pgTable("board", {
|
||||
id: bigserial("id", { mode: "number" }).primaryKey(),
|
||||
publicId: varchar("publicId", { length: 12 }).notNull().unique(),
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
createdBy: uuid("createdBy")
|
||||
.notNull()
|
||||
.references(() => users.id),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updatedAt"),
|
||||
deletedAt: timestamp("deletedAt"),
|
||||
deletedBy: uuid("deletedBy").references(() => users.id),
|
||||
importId: bigint("importId", { mode: "number" }).references(() => imports.id),
|
||||
workspaceId: bigint("workspaceId", { mode: "number" })
|
||||
.notNull()
|
||||
.references(() => workspaces.id, { onDelete: "cascade" }),
|
||||
});
|
||||
export const boards = pgTable(
|
||||
"board",
|
||||
{
|
||||
id: bigserial("id", { mode: "number" }).primaryKey(),
|
||||
publicId: varchar("publicId", { length: 12 }).notNull().unique(),
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
description: text("description"),
|
||||
slug: varchar("slug", { length: 255 }).notNull(),
|
||||
createdBy: uuid("createdBy")
|
||||
.notNull()
|
||||
.references(() => users.id),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updatedAt"),
|
||||
deletedAt: timestamp("deletedAt"),
|
||||
deletedBy: uuid("deletedBy").references(() => users.id),
|
||||
importId: bigint("importId", { mode: "number" }).references(
|
||||
() => imports.id,
|
||||
),
|
||||
workspaceId: bigint("workspaceId", { mode: "number" })
|
||||
.notNull()
|
||||
.references(() => workspaces.id, { onDelete: "cascade" }),
|
||||
},
|
||||
(table) => ({
|
||||
uniqueSlugPerWorkspace: uniqueIndex("unique_slug_per_workspace").on(
|
||||
table.workspaceId,
|
||||
table.slug,
|
||||
),
|
||||
}),
|
||||
);
|
||||
|
||||
export const boardsRelations = relations(boards, ({ one, many }) => ({
|
||||
createdBy: one(users, {
|
||||
|
||||
@@ -75,10 +75,12 @@ export type Database = {
|
||||
createdBy: string
|
||||
deletedAt: string | null
|
||||
deletedBy: string | null
|
||||
description: string | null
|
||||
id: number
|
||||
importId: number | null
|
||||
name: string
|
||||
publicId: string
|
||||
slug: string
|
||||
updatedAt: string | null
|
||||
workspaceId: number
|
||||
}
|
||||
@@ -87,10 +89,12 @@ export type Database = {
|
||||
createdBy: string
|
||||
deletedAt?: string | null
|
||||
deletedBy?: string | null
|
||||
description?: string | null
|
||||
id?: number
|
||||
importId?: number | null
|
||||
name: string
|
||||
publicId: string
|
||||
slug: string
|
||||
updatedAt?: string | null
|
||||
workspaceId: number
|
||||
}
|
||||
@@ -99,10 +103,12 @@ export type Database = {
|
||||
createdBy?: string
|
||||
deletedAt?: string | null
|
||||
deletedBy?: string | null
|
||||
description?: string | null
|
||||
id?: number
|
||||
importId?: number | null
|
||||
name?: string
|
||||
publicId?: string
|
||||
slug?: string
|
||||
updatedAt?: string | null
|
||||
workspaceId?: number
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user