Changeset 0.8.5 (#48)
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
-- ==========================================
|
||||
-- Migration 019: (superseded by 020)
|
||||
-- ==========================================
|
||||
-- Original CREATE TABLE IF NOT EXISTS was a no-op because
|
||||
-- user_model_preferences already existed from migration 005.
|
||||
-- The actual rework is in 020_user_model_preferences_rework.sql.
|
||||
-- ==========================================
|
||||
SELECT 1;
|
||||
@@ -0,0 +1,24 @@
|
||||
-- ==========================================
|
||||
-- Migration 019: User Model Preferences (rework)
|
||||
-- ==========================================
|
||||
-- The user_model_preferences table was created in 005 with:
|
||||
-- id UUID PK, user_id UUID, model_config_id UUID FK, is_enabled BOOL
|
||||
-- That schema ties preferences to model_configs rows (global only).
|
||||
-- We need string-based model_id to support personal provider models too,
|
||||
-- plus a 'hidden' column with clearer semantics.
|
||||
--
|
||||
-- Strategy: add new columns, add unique constraint for UPSERT.
|
||||
-- Old columns (model_config_id, is_enabled) remain for backward compat.
|
||||
-- ==========================================
|
||||
|
||||
-- Add new columns if they don't exist
|
||||
ALTER TABLE user_model_preferences ADD COLUMN IF NOT EXISTS model_id VARCHAR(255);
|
||||
ALTER TABLE user_model_preferences ADD COLUMN IF NOT EXISTS hidden BOOLEAN DEFAULT false;
|
||||
ALTER TABLE user_model_preferences ADD COLUMN IF NOT EXISTS updated_at TIMESTAMPTZ DEFAULT NOW();
|
||||
|
||||
-- Make model_config_id nullable (new rows use model_id instead)
|
||||
ALTER TABLE user_model_preferences ALTER COLUMN model_config_id DROP NOT NULL;
|
||||
|
||||
-- Unique constraint for UPSERT — NULLs are distinct in PG so old rows won't conflict
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_user_model_pref_user_model
|
||||
ON user_model_preferences (user_id, model_id);
|
||||
Reference in New Issue
Block a user