feat(saas): add down migrations for all incremental schema changes (AUD3-DB-01)
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
Some checks failed
CI / Lint & TypeCheck (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
CI / Build Frontend (push) Has been cancelled
CI / Rust Check (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
CI / E2E Tests (push) Has been cancelled
- 16 down SQL files in migrations/down/ for each incremental migration - db::run_down_migrations() executes rollback files in reverse order - migrate_down CLI task: task=migrate_down timestamp=20260402 - Initial schema and seed data excluded (would be destructive)
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
-- Down: Drop scheduled_tasks table
|
||||
DROP TABLE IF EXISTS scheduled_tasks;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Down: Remove llm_routing column from accounts
|
||||
ALTER TABLE accounts DROP COLUMN IF EXISTS llm_routing;
|
||||
@@ -0,0 +1,11 @@
|
||||
-- Down: Remove extension columns from agent_templates
|
||||
DROP INDEX IF EXISTS idx_agent_templates_source_id;
|
||||
ALTER TABLE agent_templates DROP COLUMN IF EXISTS source_id;
|
||||
ALTER TABLE agent_templates DROP COLUMN IF EXISTS version;
|
||||
ALTER TABLE agent_templates DROP COLUMN IF EXISTS emoji;
|
||||
ALTER TABLE agent_templates DROP COLUMN IF EXISTS communication_style;
|
||||
ALTER TABLE agent_templates DROP COLUMN IF EXISTS personality;
|
||||
ALTER TABLE agent_templates DROP COLUMN IF EXISTS quick_commands;
|
||||
ALTER TABLE agent_templates DROP COLUMN IF EXISTS welcome_message;
|
||||
ALTER TABLE agent_templates DROP COLUMN IF EXISTS scenarios;
|
||||
ALTER TABLE agent_templates DROP COLUMN IF EXISTS soul_content;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Down: Remove last_used_at from provider_keys
|
||||
ALTER TABLE provider_keys DROP COLUMN IF EXISTS last_used_at;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Down: Re-add quota_reset_interval to provider_keys
|
||||
ALTER TABLE provider_keys ADD COLUMN IF NOT EXISTS quota_reset_interval TEXT;
|
||||
@@ -0,0 +1,5 @@
|
||||
-- Down: Remove is_embedding and model_type from models
|
||||
DROP INDEX IF EXISTS idx_models_model_type;
|
||||
DROP INDEX IF EXISTS idx_models_is_embedding;
|
||||
ALTER TABLE models DROP COLUMN IF EXISTS model_type;
|
||||
ALTER TABLE models DROP COLUMN IF EXISTS is_embedding;
|
||||
@@ -0,0 +1,4 @@
|
||||
-- Down: Remove password security columns from accounts
|
||||
ALTER TABLE accounts DROP COLUMN IF EXISTS locked_until;
|
||||
ALTER TABLE accounts DROP COLUMN IF EXISTS failed_login_count;
|
||||
ALTER TABLE accounts DROP COLUMN IF EXISTS password_version;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Down: Drop rate_limit_events table
|
||||
DROP TABLE IF EXISTS rate_limit_events;
|
||||
@@ -0,0 +1,6 @@
|
||||
-- Down: Drop billing tables (reverse creation order due to FK)
|
||||
DROP TABLE IF EXISTS billing_usage_quotas;
|
||||
DROP TABLE IF EXISTS billing_payments;
|
||||
DROP TABLE IF EXISTS billing_invoices;
|
||||
DROP TABLE IF EXISTS billing_subscriptions;
|
||||
DROP TABLE IF EXISTS billing_plans;
|
||||
@@ -0,0 +1,7 @@
|
||||
-- Down: Drop knowledge base tables (reverse creation order due to FK)
|
||||
-- Note: This does NOT reverse the pgvector extension installation or role permission updates.
|
||||
DROP TABLE IF EXISTS knowledge_usage;
|
||||
DROP TABLE IF EXISTS knowledge_versions;
|
||||
DROP TABLE IF EXISTS knowledge_chunks;
|
||||
DROP TABLE IF EXISTS knowledge_items;
|
||||
DROP TABLE IF EXISTS knowledge_categories;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- Down: Remove result columns from scheduled_tasks
|
||||
ALTER TABLE scheduled_tasks DROP COLUMN IF EXISTS last_duration_ms;
|
||||
ALTER TABLE scheduled_tasks DROP COLUMN IF EXISTS last_result;
|
||||
@@ -0,0 +1,2 @@
|
||||
-- Down: Remove assigned_template_id from accounts
|
||||
ALTER TABLE accounts DROP COLUMN IF EXISTS assigned_template_id;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- Down: Drop webhook tables (reverse creation order due to FK)
|
||||
DROP TABLE IF EXISTS webhook_deliveries;
|
||||
DROP TABLE IF EXISTS webhook_subscriptions;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- Down: Drop model group tables (reverse creation order due to FK)
|
||||
DROP TABLE IF EXISTS model_group_members;
|
||||
DROP TABLE IF EXISTS model_groups;
|
||||
@@ -0,0 +1,6 @@
|
||||
-- Down: Remove industry agent template seed data
|
||||
DELETE FROM agent_templates WHERE id IN (
|
||||
'edu-teacher-001',
|
||||
'healthcare-admin-001',
|
||||
'design-shantou-001'
|
||||
);
|
||||
Reference in New Issue
Block a user