生产迁移安全策略禁止在已有任务表上直接新增非空列。兼容提交响应读取已使用 COALESCE,因此将 JSONB 元数据列改为可空,不改变接口行为。 验证:ci-validate-migrations.mjs;migrations-test.sh;go test ./internal/store ./internal/httpapi。
19 lines
878 B
SQL
19 lines
878 B
SQL
ALTER TABLE gateway_tasks
|
|
ADD COLUMN IF NOT EXISTS compatibility_protocol text,
|
|
ADD COLUMN IF NOT EXISTS compatibility_public_id text,
|
|
ADD COLUMN IF NOT EXISTS compatibility_source_protocol text,
|
|
ADD COLUMN IF NOT EXISTS compatibility_submit_http_status integer,
|
|
ADD COLUMN IF NOT EXISTS compatibility_submit_headers jsonb,
|
|
ADD COLUMN IF NOT EXISTS compatibility_submit_body jsonb;
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS gateway_tasks_compatibility_public_id_unique
|
|
ON gateway_tasks (compatibility_protocol, compatibility_public_id)
|
|
WHERE compatibility_protocol IS NOT NULL
|
|
AND compatibility_protocol <> ''
|
|
AND compatibility_public_id IS NOT NULL
|
|
AND compatibility_public_id <> '';
|
|
|
|
CREATE INDEX IF NOT EXISTS gateway_tasks_remote_task_compatibility_lookup
|
|
ON gateway_tasks (remote_task_id)
|
|
WHERE remote_task_id IS NOT NULL AND remote_task_id <> '';
|