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.
This commit is contained in:
2026-04-02 00:31:28 +08:00
parent de30497f59
commit b31d8d0096
101 changed files with 16671 additions and 721 deletions
@@ -1,11 +1,24 @@
-- name: CreateAuditLog :exec
INSERT INTO audit_logs (operator_id, tenant_id, module, action, before_json, after_json, result)
INSERT INTO audit_logs (
operator_id,
tenant_id,
module,
action,
resource_type,
resource_id,
request_id,
before_json,
after_json,
result,
error_message
)
VALUES (sqlc.arg(operator_id), sqlc.arg(tenant_id), sqlc.arg(module), sqlc.arg(action),
sqlc.arg(before_json), sqlc.arg(after_json), sqlc.arg(result));
sqlc.arg(resource_type), sqlc.arg(resource_id), sqlc.arg(request_id),
sqlc.arg(before_json), sqlc.arg(after_json), sqlc.arg(result), sqlc.arg(error_message));
-- name: CreateGenerationTask :one
INSERT INTO generation_tasks (tenant_id, article_id, quota_reservation_id, task_type, input_params_json, status)
VALUES (sqlc.arg(tenant_id), sqlc.arg(article_id), sqlc.arg(quota_reservation_id),
INSERT INTO generation_tasks (tenant_id, operator_id, article_id, quota_reservation_id, task_type, input_params_json, status)
VALUES (sqlc.arg(tenant_id), sqlc.arg(operator_id), sqlc.arg(article_id), sqlc.arg(quota_reservation_id),
sqlc.arg(task_type), sqlc.arg(input_params_json), 'queued')
RETURNING id;