Files
geo/server/migrations/20260401143000_harden_task_audit_tracking.down.sql
T
root b31d8d0096 feat(migrations): Harden task audit tracking and optimize article templates
- Added migration to harden task audit tracking by modifying audit_logs and related tables.
- Introduced operator_id to several tables for better tracking of actions.
- Updated article_templates with new prompt templates for various article types, enhancing content generation.
- Created prompt_rules and schedule_tasks tables to manage content generation rules and scheduling.
- Added foreign key constraints to articles for better data integrity.
2026-04-02 00:31:28 +08:00

40 lines
1.3 KiB
SQL

DROP INDEX IF EXISTS uk_template_tenant_key_version_active;
DROP INDEX IF EXISTS uk_template_platform_key_version_active;
CREATE UNIQUE INDEX uk_template_scope_key_version_active
ON article_templates(scope, tenant_id, template_key, version_no)
WHERE deleted_at IS NULL;
DROP INDEX IF EXISTS idx_audit_tenant_operator_created;
DROP INDEX IF EXISTS idx_quota_reservations_tenant_operator_created;
DROP INDEX IF EXISTS idx_quota_ledgers_tenant_operator_created;
DROP INDEX IF EXISTS idx_task_record_tenant_operator_created;
DROP INDEX IF EXISTS idx_template_assist_tasks_tenant_operator_created;
DROP INDEX IF EXISTS idx_generation_task_tenant_operator_created;
ALTER TABLE audit_logs
DROP COLUMN IF EXISTS error_message,
DROP COLUMN IF EXISTS request_id,
DROP COLUMN IF EXISTS resource_id,
DROP COLUMN IF EXISTS resource_type;
UPDATE quota_reservations
SET resource_id = 0
WHERE resource_id IS NULL;
ALTER TABLE quota_reservations
DROP COLUMN IF EXISTS operator_id,
ALTER COLUMN resource_id SET NOT NULL;
ALTER TABLE tenant_quota_ledgers
DROP COLUMN IF EXISTS operator_id;
ALTER TABLE task_records
DROP COLUMN IF EXISTS operator_id;
ALTER TABLE template_assist_tasks
DROP COLUMN IF EXISTS operator_id;
ALTER TABLE generation_tasks
DROP COLUMN IF EXISTS operator_id;