feat: backend MVP (auth/rbac, catalog, orders, fulfillment, invoices) + specs + scaffolds

This commit is contained in:
Chengdong Zhang
2026-09-17 12:43:22 +08:00
commit dc9fd31c5e
96 changed files with 17550 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
CREATE TYPE user_role AS ENUM ('platform_admin', 'shop_owner', 'shop_staff', 'customer');
CREATE TYPE shop_status AS ENUM ('active', 'suspended');
CREATE TABLE shops (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
name JSONB NOT NULL,
slug TEXT NOT NULL UNIQUE,
status shop_status NOT NULL DEFAULT 'active',
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE TABLE users (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
email TEXT NOT NULL UNIQUE,
password_hash TEXT NOT NULL,
display_name TEXT NOT NULL,
role user_role NOT NULL DEFAULT 'customer',
shop_id UUID REFERENCES shops (id),
locale TEXT NOT NULL DEFAULT 'en',
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
CONSTRAINT shop_role_requires_shop CHECK (
role IN ('customer', 'platform_admin')
OR shop_id IS NOT NULL
)
);
CREATE INDEX idx_users_shop ON users (shop_id);