feat(18-01): add globalItems, itemGlobalLinks tables and user profile/setup visibility columns

- Add globalItems table with brand, model, category, weightGrams, priceCents, imageUrl, description
- Add itemGlobalLinks junction table linking user items to global items (unique per item)
- Add displayName, avatarUrl, bio nullable columns to users table
- Add isPublic boolean column to setups table (default false)
- Import boolean from drizzle-orm/pg-core
- Generate migration 0001_tough_boomerang.sql
This commit is contained in:
2026-04-05 12:57:49 +02:00
parent 37d5711475
commit 82657038cc
4 changed files with 1157 additions and 0 deletions

View File

@@ -1,4 +1,5 @@
import {
boolean,
doublePrecision,
integer,
pgTable,
@@ -14,6 +15,9 @@ import {
export const users = pgTable("users", {
id: serial("id").primaryKey(),
logtoSub: text("logto_sub").notNull().unique(),
displayName: text("display_name"),
avatarUrl: text("avatar_url"),
bio: text("bio"),
createdAt: timestamp("created_at").defaultNow().notNull(),
});
@@ -105,6 +109,7 @@ export const setups = pgTable("setups", {
userId: integer("user_id")
.notNull()
.references(() => users.id),
isPublic: boolean("is_public").notNull().default(false),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow().notNull(),
});
@@ -122,6 +127,33 @@ export const setupItems = pgTable("setup_items", {
classification: text("classification").notNull().default("base"),
});
// ── Global Items ────────────────────────────────────────────────────
export const globalItems = pgTable("global_items", {
id: serial("id").primaryKey(),
brand: text("brand").notNull(),
model: text("model").notNull(),
category: text("category"),
weightGrams: doublePrecision("weight_grams"),
priceCents: integer("price_cents"),
imageUrl: text("image_url"),
description: text("description"),
createdAt: timestamp("created_at").defaultNow().notNull(),
});
// ── Item Global Links ───────────────────────────────────────────────
export const itemGlobalLinks = pgTable("item_global_links", {
id: serial("id").primaryKey(),
itemId: integer("item_id")
.notNull()
.references(() => items.id, { onDelete: "cascade" })
.unique(),
globalItemId: integer("global_item_id")
.notNull()
.references(() => globalItems.id, { onDelete: "cascade" }),
});
// ── Settings ────────────────────────────────────────────────────────
export const settings = pgTable(