created list schema
This commit is contained in:
38
src/server/db/schema/app.ts
Normal file
38
src/server/db/schema/app.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import { relations } from "drizzle-orm";
|
||||
import { boolean, integer, serial, text, varchar } from "drizzle-orm/pg-core";
|
||||
import { VARIANTS } from "~/lib/data/list-variants";
|
||||
import { LABELS } from "~/lib/data/task-labels";
|
||||
import { PRIORITIES } from "~/lib/data/task-priority";
|
||||
import { STATUSES } from "~/lib/data/task-status";
|
||||
import { users } from "~/server/db/schema/auth";
|
||||
import { createTable } from "~/server/db/schema/create-table";
|
||||
|
||||
export const lists = createTable("list", {
|
||||
id: serial("id").primaryKey(),
|
||||
userId: varchar("userId", { length: 255 }).notNull(),
|
||||
title: varchar("title", { length: 128 }).notNull(),
|
||||
variant: varchar("variant", { enum: VARIANTS }).notNull(),
|
||||
labels: text("labels"),
|
||||
showId: boolean("showId").default(false).notNull(),
|
||||
idPrefix: varchar("idPrefix", { length: 8 }),
|
||||
lastTaskId: integer("lastTaskId").default(0).notNull(),
|
||||
});
|
||||
|
||||
export const listRelations = relations(lists, ({ one }) => ({
|
||||
user: one(users, { fields: [lists.userId], references: [users.id] }),
|
||||
}));
|
||||
|
||||
export const tasks = createTable("task", {
|
||||
id: serial("id").primaryKey(),
|
||||
listId: serial("listId").notNull(),
|
||||
title: varchar("title", { length: 128 }).notNull(),
|
||||
isChecked: boolean("isChecked").default(false).notNull(),
|
||||
visibleId: varchar("visibleId", { length: 16 }),
|
||||
label: varchar("label", { enum: LABELS }),
|
||||
status: varchar("status", { enum: STATUSES }),
|
||||
priority: varchar("priority", { enum: PRIORITIES }),
|
||||
});
|
||||
|
||||
export const taskRelations = relations(tasks, ({ one }) => ({
|
||||
list: one(lists, { fields: [tasks.listId], references: [lists.id] }),
|
||||
}));
|
||||
Reference in New Issue
Block a user