sql数据流,amdin业务逻辑接入

This commit is contained in:
comlibmb
2026-02-05 10:11:09 +08:00
parent 859372ca5b
commit ac670cf5d8
81 changed files with 3547 additions and 1472 deletions

0
docs/sql/10_schema/.keep Normal file
View File

View File

@@ -0,0 +1,8 @@
# docs/sql/10_schema
本目录存放:
- 表/类型/索引等 DDL
- 按域分组(如 `analytics/``user/``order/` 等)
- 文件命名:`<object>_v<version>.sql`
**禁止**:在此目录混入 RLS、RPC、GRANT 等对象。

View File

@@ -0,0 +1,19 @@
-- =====================================================================================
-- Schema: public.ak_users
-- Version: v1
-- Purpose: 修复 auth.users -> ak_users 自动同步的写入协调问题
-- Change: 放宽 username 和 email 的 NOT NULL 约束,以允许数据库触发器成功插入新用户记录。
-- 同时,将 role 的默认值更新为 'customer' 以符合业务逻辑。
-- =====================================================================================
BEGIN;
-- 步骤 1 & 2: 允许 username/email 为空,并更新 role 默认值
-- 这样数据库的自动用户同步触发器就不会因为缺少 NOT NULL 的值而失败。
-- 前端代码 (ensureUserProfile) 会在用户首次登录时尝试填充这些值。
ALTER TABLE public.ak_users
ALTER COLUMN username DROP NOT NULL,
ALTER COLUMN email DROP NOT NULL,
ALTER COLUMN role SET DEFAULT 'customer';
COMMIT;