Add Drizzle + Postgres setup (task 03)
drizzle-orm + postgres driver + drizzle-kit wired up. Core schema declares users, households, and household_members. docker-compose.dev.yaml runs Postgres 16 locally. Initial migration generated and verified applied. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
09d6adbf18
commit
37977568ed
@@ -0,0 +1,30 @@
|
||||
import { pgEnum, pgTable, primaryKey, timestamp, uuid, varchar } from "drizzle-orm/pg-core";
|
||||
|
||||
export const roleEnum = pgEnum("household_member_role", ["owner", "member"]);
|
||||
|
||||
export const users = pgTable("users", {
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
email: varchar("email", { length: 255 }).notNull().unique(),
|
||||
displayName: varchar("display_name", { length: 255 }).notNull(),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
});
|
||||
|
||||
export const households = pgTable("households", {
|
||||
id: uuid("id").primaryKey().defaultRandom(),
|
||||
name: varchar("name", { length: 255 }).notNull(),
|
||||
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
||||
});
|
||||
|
||||
export const householdMembers = pgTable(
|
||||
"household_members",
|
||||
{
|
||||
householdId: uuid("household_id")
|
||||
.notNull()
|
||||
.references(() => households.id, { onDelete: "cascade" }),
|
||||
userId: uuid("user_id")
|
||||
.notNull()
|
||||
.references(() => users.id, { onDelete: "cascade" }),
|
||||
role: roleEnum("role").notNull().default("member"),
|
||||
},
|
||||
(t) => [primaryKey({ columns: [t.householdId, t.userId] })],
|
||||
);
|
||||
Reference in New Issue
Block a user