Files
gochat/backend/migrations/000050_add_captain_auto_reply_rules.up.sql
T
rogee ee8fbb3df2 Fix duplicate migration version numbers (000048/000049)
Renumber migrations from merged feature/ai-feature-activation branch
to resolve golang-migrate duplicate version conflict:
- 000048_add_captain_auto_reply_rules → 000050
- 000049_add_article_embedding_vector → 000051

Both migrations were already applied to the database; schema_migrations
version updated from 49 to 51 to reflect the new numbering.
2026-07-08 16:28:40 +08:00

31 lines
1.7 KiB
SQL

-- 000050_add_captain_auto_reply_rules.up.sql
-- Captain AI — Auto-Reply Rules table
-- Reference: M12 PRD §Captain AI — Auto-Reply Rules
-- Stores rules for automated replies when incoming messages match conditions.
CREATE TABLE IF NOT EXISTS captain_auto_reply_rules (
id BIGSERIAL PRIMARY KEY,
account_id BIGINT NOT NULL,
assistant_id BIGINT NOT NULL,
inbox_id BIGINT NULL,
name VARCHAR(255) NOT NULL,
description TEXT DEFAULT '',
status VARCHAR(50) NOT NULL DEFAULT 'draft',
mode VARCHAR(50) NOT NULL DEFAULT 'static',
priority INTEGER NOT NULL DEFAULT 0,
conditions JSONB NOT NULL DEFAULT '[]'::jsonb,
response_text TEXT DEFAULT '',
llm_prompt_override TEXT DEFAULT '',
delay_seconds INTEGER NOT NULL DEFAULT 0,
one_time_only BOOLEAN NOT NULL DEFAULT TRUE,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
deleted_at TIMESTAMP WITH TIME ZONE NULL
);
CREATE INDEX IF NOT EXISTS idx_captain_auto_reply_rules_account_id ON captain_auto_reply_rules(account_id);
CREATE INDEX IF NOT EXISTS idx_captain_auto_reply_rules_assistant_id ON captain_auto_reply_rules(assistant_id);
CREATE INDEX IF NOT EXISTS idx_captain_auto_reply_rules_inbox_id ON captain_auto_reply_rules(inbox_id);
CREATE INDEX IF NOT EXISTS idx_captain_auto_reply_rules_status ON captain_auto_reply_rules(status);
CREATE INDEX IF NOT EXISTS idx_captain_auto_reply_rules_deleted_at ON captain_auto_reply_rules(deleted_at);