Files
cloud-host/backend/helm/cloudhost-platform/migrations/014_application_migrations.sql
T
keyhan bf9e827f85 Add cloudhost-platform Helm chart and registry ingress manifests.
Deploy backend, frontend, PostgreSQL, and Redis on Kubernetes with optional Ingress/TLS, SQL migration hooks, and public registry exposure at repo.3fase.ir.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-24 19:01:05 +03:30

37 lines
1.5 KiB
SQL

CREATE TABLE IF NOT EXISTS application_migration_jobs (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"applicationId" UUID NOT NULL REFERENCES applications(id) ON DELETE CASCADE,
"requestedBy" UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
"sourceClusterId" UUID NOT NULL REFERENCES clusters(id) ON DELETE RESTRICT,
"targetClusterId" UUID NOT NULL REFERENCES clusters(id) ON DELETE RESTRICT,
status VARCHAR NOT NULL DEFAULT 'queued',
attempts INTEGER NOT NULL DEFAULT 0,
"maxAttempts" INTEGER NOT NULL DEFAULT 3,
"currentStep" VARCHAR,
"errorMessage" VARCHAR,
metadata JSONB,
"startedAt" TIMESTAMPTZ,
"completedAt" TIMESTAMPTZ,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT NOW(),
"updatedAt" TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_application_migration_jobs_app_created
ON application_migration_jobs("applicationId", "createdAt" DESC);
CREATE INDEX IF NOT EXISTS idx_application_migration_jobs_status
ON application_migration_jobs(status);
CREATE TABLE IF NOT EXISTS application_migration_events (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"migrationId" UUID NOT NULL REFERENCES application_migration_jobs(id) ON DELETE CASCADE,
step VARCHAR NOT NULL,
level VARCHAR NOT NULL DEFAULT 'info',
message VARCHAR NOT NULL,
metadata JSONB,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_application_migration_events_migration_created
ON application_migration_events("migrationId", "createdAt" ASC);