Skip to content
Clone
61e78d8
26 lines 1.5 KB SQL
-- schema_pre_sync.sql
-- Drops partial unique indexes created by schema_extras.sql before every
-- sea-orm schema sync. The sync layer cannot express partial predicates via
-- entity attributes, and treats these manually-created unique indexes as
-- stale constraints (DROP CONSTRAINT), which fails because they are plain
-- indexes. schema_extras.sql recreates all of them after the sync succeeds.
DROP INDEX IF EXISTS idx_issue_watch_issue_user;
DROP INDEX IF EXISTS idx_issue_watch_project_user;
DROP INDEX IF EXISTS idx_issue_reaction_issue;
DROP INDEX IF EXISTS idx_issue_reaction_comment;
DROP INDEX IF EXISTS idx_issue_reaction_project;
DROP INDEX IF EXISTS idx_branch_protection_whitelist_user;
DROP INDEX IF EXISTS idx_branch_protection_whitelist_group;
DROP INDEX IF EXISTS idx_chat_message_room_nonce;
DROP INDEX IF EXISTS idx_chat_dm_pair;
DROP INDEX IF EXISTS idx_chat_draft_unique;
-- idempotent column adds for phase-2 model changes (sync layer cannot
-- express NOT NULL DEFAULT additions on populated tables)
ALTER TABLE room_members ADD COLUMN IF NOT EXISTS role SMALLINT NOT NULL DEFAULT 0;
ALTER TABLE issue ADD COLUMN IF NOT EXISTS priority SMALLINT NOT NULL DEFAULT 0;
ALTER TABLE issue ADD COLUMN IF NOT EXISTS due_at TIMESTAMP WITH TIME ZONE;
ALTER TABLE user_access_key ADD COLUMN IF NOT EXISTS expires_at TIMESTAMP WITH TIME ZONE;
ALTER TABLE user_access_key ADD COLUMN IF NOT EXISTS last_used_at TIMESTAMP WITH TIME ZONE;
ALTER TABLE chat_message_reminder ADD COLUMN IF NOT EXISTS note TEXT;