mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-02 14:56:38 +08:00
refactor(migration): merge per-plugin SQL into single initial migration
Each plugin now has exactly one migration file (00001_initial.sql) containing its complete table schema and seed data, replacing the multi-file approach with split ALTER/INSERT steps. Changes per plugin: - auth: w_auth_sources, w_external_accounts, w_access_tokens + login session seed - user: w_users + system user seed (removed w_access_tokens — belongs to auth) - admin: w_system_configs, w_templates + all 32 config seeds + 2 template seeds (removed w_schedules, w_task_executions — belong to driver plugins) - upload: w_upload_stats + indexes + access_mode + backfill - message_gateway: all w_message_*, w_push_*, w_push_channels, w_push_histories - risk_control/logstore: w_user_access_logs (PG + ClickHouse) - driver_asynq_cron: w_schedules + cleanup seed - driver_asynq_worker: w_task_executions All CREATE TABLE use IF NOT EXISTS, all INSERT use ON CONFLICT DO NOTHING. go:embed patterns remain 'migrations/*.sql' — unchanged.
This commit is contained in:
+1
-1
@@ -13,7 +13,7 @@ CREATE INDEX IF NOT EXISTS idx_w_schedules_is_active ON w_schedules (is_active);
|
||||
|
||||
-- Seed initial cleanup task
|
||||
INSERT INTO w_schedules (id, name, task_type, cron, payload, is_active, created_at, updated_at)
|
||||
VALUES (1, '清理未使用上传', 'cleanup_unused_uploads', '0 */2 * * *', '{}', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
|
||||
VALUES (1, '系统定期垃圾清理', 'system_cleanup', '0 3 * * *', '{}', TRUE, CURRENT_TIMESTAMP, CURRENT_TIMESTAMP)
|
||||
ON CONFLICT (id) DO NOTHING;
|
||||
|
||||
-- +goose Down
|
||||
@@ -1,5 +0,0 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE w_schedules ALTER COLUMN id ADD GENERATED BY DEFAULT AS IDENTITY (START WITH 100);
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE w_schedules ALTER COLUMN id DROP IDENTITY IF EXISTS;
|
||||
@@ -1,11 +0,0 @@
|
||||
-- +goose Up
|
||||
UPDATE w_schedules
|
||||
SET name = '系统定期垃圾清理',
|
||||
task_type = 'system_cleanup'
|
||||
WHERE id = 1;
|
||||
|
||||
-- +goose Down
|
||||
UPDATE w_schedules
|
||||
SET name = '清理未使用上传',
|
||||
task_type = 'cleanup_unused_uploads'
|
||||
WHERE id = 1;
|
||||
Reference in New Issue
Block a user