feat: card checklists (#141)
* feat: setup checklist schema * feat: scaffold checklist router * feat: add create new checklist modal * feat: create new checklist item * feat: toggle checklist item completed state * feat: update checklist name * feat: delete checklist * feat: show checklists progress on cards * feat: tweak light mode styling * feat: focus item form on creation of new checklist * feat: tweak new checklist item form styling * feat: add checklist activity * feat: show checklist progress on public board page * feat: display checklist items on public card modal * chore: add translations
This commit is contained in:
90
packages/db/src/schema/checklists.ts
Normal file
90
packages/db/src/schema/checklists.ts
Normal file
@@ -0,0 +1,90 @@
|
||||
import { relations } from "drizzle-orm";
|
||||
import {
|
||||
bigint,
|
||||
bigserial,
|
||||
boolean,
|
||||
integer,
|
||||
pgTable,
|
||||
timestamp,
|
||||
uuid,
|
||||
varchar,
|
||||
} from "drizzle-orm/pg-core";
|
||||
|
||||
import { cards } from "./cards";
|
||||
import { users } from "./users";
|
||||
|
||||
export const checklists = pgTable("card_checklist", {
|
||||
id: bigserial("id", { mode: "number" }).primaryKey(),
|
||||
publicId: varchar("publicId", { length: 12 }).notNull().unique(),
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
index: integer("index").notNull(),
|
||||
cardId: bigint("cardId", { mode: "number" })
|
||||
.notNull()
|
||||
.references(() => cards.id, { onDelete: "cascade" }),
|
||||
createdBy: uuid("createdBy").references(() => users.id, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updatedAt"),
|
||||
deletedAt: timestamp("deletedAt"),
|
||||
deletedBy: uuid("deletedBy").references(() => users.id, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
}).enableRLS();
|
||||
|
||||
export const checklistsRelations = relations(checklists, ({ one, many }) => ({
|
||||
card: one(cards, {
|
||||
fields: [checklists.cardId],
|
||||
references: [cards.id],
|
||||
relationName: "checklistsCard",
|
||||
}),
|
||||
createdBy: one(users, {
|
||||
fields: [checklists.createdBy],
|
||||
references: [users.id],
|
||||
relationName: "checklistsCreatedByUser",
|
||||
}),
|
||||
deletedBy: one(users, {
|
||||
fields: [checklists.deletedBy],
|
||||
references: [users.id],
|
||||
relationName: "checklistsDeletedByUser",
|
||||
}),
|
||||
items: many(checklistItems),
|
||||
}));
|
||||
|
||||
export const checklistItems = pgTable("card_checklist_item", {
|
||||
id: bigserial("id", { mode: "number" }).primaryKey(),
|
||||
publicId: varchar("publicId", { length: 12 }).notNull().unique(),
|
||||
title: varchar("title", { length: 500 }).notNull(),
|
||||
completed: boolean("completed").notNull().default(false),
|
||||
index: integer("index").notNull(),
|
||||
checklistId: bigint("checklistId", { mode: "number" })
|
||||
.notNull()
|
||||
.references(() => checklists.id, { onDelete: "cascade" }),
|
||||
createdBy: uuid("createdBy").references(() => users.id, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
createdAt: timestamp("createdAt").defaultNow().notNull(),
|
||||
updatedAt: timestamp("updatedAt"),
|
||||
deletedAt: timestamp("deletedAt"),
|
||||
deletedBy: uuid("deletedBy").references(() => users.id, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
}).enableRLS();
|
||||
|
||||
export const checklistItemsRelations = relations(checklistItems, ({ one }) => ({
|
||||
checklist: one(checklists, {
|
||||
fields: [checklistItems.checklistId],
|
||||
references: [checklists.id],
|
||||
relationName: "checklistItemsChecklist",
|
||||
}),
|
||||
createdBy: one(users, {
|
||||
fields: [checklistItems.createdBy],
|
||||
references: [users.id],
|
||||
relationName: "checklistItemsCreatedByUser",
|
||||
}),
|
||||
deletedBy: one(users, {
|
||||
fields: [checklistItems.deletedBy],
|
||||
references: [users.id],
|
||||
relationName: "checklistItemsDeletedByUser",
|
||||
}),
|
||||
}));
|
||||
Reference in New Issue
Block a user