B 設備管理(feature-device-mgmt-tdd): - POST /api/devices/:id/register + /unregister(owner 檢查 + representative 擋 + 已註冊擋 + SetRegistered 單欄翻轉,不碰 unpair 軟刪) - error codes ALREADY_REGISTERED / REPRESENTATIVE_DEVICE(409) - 不需 migration(registered_at 欄/index/讀寫已在 0005) C 模型共享(feature-model-sharing-tdd,security 深審 APPROVE): - migration 0006:models.visibility enum DEFAULT 'private'(零行為改變)+ model_shares 表 - canAccessModel single source(owner ∪ share ∪ public ∪ tenant):profile + download 共用 - GET /library(cursor keyset)/ GET /:id/profile(404 防列舉、GetWithOwner join name 不洩 email) / PATCH /:id/visibility(owner-only)/ shares CRUD / download 放寬 - tenant 因 OIDC 無 org claim 留 stub(恆空、安全預設;補 org claim 需重送 security 深審) reviewer 通過(B 三條紅線 / C security APPROVE 無 C/M)。130 dbtest 全綠、gosec 新檔 0。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
18 lines
821 B
SQL
18 lines
821 B
SQL
-- 0006_model_sharing.down.sql
|
||
--
|
||
-- 反向 0006:對稱移除 model_shares 表、models.visibility 欄與相關 index / constraint。
|
||
-- 順序:先刪依賴 visibility 的 partial index → 刪 model_shares 表(其 index 隨表 DROP 自動移除)
|
||
-- → 刪 models 的 constraint + 欄位。
|
||
|
||
-- (3) 共享庫查詢 index。
|
||
DROP INDEX IF EXISTS idx_models_public_active;
|
||
|
||
-- (2) model_shares 表(idx_model_shares_grantee 隨表 DROP 自動移除)。
|
||
DROP TABLE IF EXISTS model_shares;
|
||
|
||
-- (1) models.visibility 欄與其 CHECK constraint。
|
||
-- 先 DROP CONSTRAINT 再 DROP COLUMN(DROP COLUMN 也會連帶移除 constraint,
|
||
-- 此處顯式先移以求對稱清楚)。
|
||
ALTER TABLE models DROP CONSTRAINT IF EXISTS chk_models_visibility;
|
||
ALTER TABLE models DROP COLUMN IF EXISTS visibility;
|