ai-chatbot/lib/db/migrations/0047_add_storage_migration_tasks.sql
Your Name bd418a3fdb
Some checks failed
Lint / build (20) (push) Has been cancelled
Playwright Tests / test (push) Has been cancelled
feat(storage): add aliyun oss auto migration and cleanup pipeline
2026-03-05 12:05:24 +08:00

24 lines
925 B
SQL

CREATE TABLE IF NOT EXISTS "StorageMigrationTask" (
"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
"sourceUrl" text NOT NULL UNIQUE,
"sourcePath" text NOT NULL,
"sourceStorageConfigId" uuid REFERENCES "StorageConfig"("id"),
"targetStorageConfigId" uuid REFERENCES "StorageConfig"("id"),
"targetUrl" text,
"status" varchar(32) NOT NULL DEFAULT 'pending',
"attemptCount" integer NOT NULL DEFAULT 0,
"lastError" text,
"migrateAfterAt" timestamp NOT NULL,
"cleanupAfterAt" timestamp NOT NULL,
"migratedAt" timestamp,
"cleanedAt" timestamp,
"createdAt" timestamp NOT NULL DEFAULT now(),
"updatedAt" timestamp NOT NULL DEFAULT now()
);
CREATE INDEX IF NOT EXISTS "StorageMigrationTask_status_migrate_idx"
ON "StorageMigrationTask"("status", "migrateAfterAt");
CREATE INDEX IF NOT EXISTS "StorageMigrationTask_status_cleanup_idx"
ON "StorageMigrationTask"("status", "cleanupAfterAt");