Implement lists module and dev login setup

This commit is contained in:
ginnoir
2026-05-06 03:49:03 -05:00
parent 744c1119a9
commit 7e3ae6eb04
31 changed files with 1525 additions and 63 deletions
+46
View File
@@ -0,0 +1,46 @@
import { index, integer, pgTable, text, timestamp, uuid, boolean } from "drizzle-orm/pg-core";
import { households, users } from "../_core/schema";
export const lists = pgTable(
"lists",
{
id: uuid("id").primaryKey().defaultRandom(),
householdId: uuid("household_id")
.notNull()
.references(() => households.id, { onDelete: "cascade" }),
type: text("type").notNull(),
name: text("name").notNull(),
archived: boolean("archived").notNull().default(false),
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
},
(t) => [
index("lists_household_type_idx").on(t.householdId, t.type),
index("lists_household_archived_idx").on(t.householdId, t.archived),
],
);
export const listItems = pgTable(
"list_items",
{
id: uuid("id").primaryKey().defaultRandom(),
listId: uuid("list_id")
.notNull()
.references(() => lists.id, { onDelete: "cascade" }),
text: text("text").notNull(),
done: boolean("done").notNull().default(false),
qty: text("qty"),
notes: text("notes"),
dueAt: timestamp("due_at", { withTimezone: true }),
assigneeId: uuid("assignee_id").references(() => users.id, { onDelete: "set null" }),
position: integer("position").notNull().default(0),
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
},
(t) => [
index("list_items_list_position_idx").on(t.listId, t.position),
index("list_items_assignee_idx").on(t.assigneeId),
],
);
export type List = typeof lists.$inferSelect;
export type ListItem = typeof listItems.$inferSelect;