Files
cloud-host/backend/helm/cloudhost-platform/migrations/003_resource_credits.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

25 lines
873 B
SQL

CREATE TABLE IF NOT EXISTS resource_credits (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
"userId" UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE,
"sourceAppName" VARCHAR,
runtime VARCHAR NOT NULL,
"databaseType" VARCHAR NOT NULL,
"cpuLimit" VARCHAR NOT NULL,
"memoryLimit" VARCHAR NOT NULL,
replicas INT NOT NULL DEFAULT 1,
"dbStorageSize" VARCHAR,
"appStorageSize" VARCHAR,
"enableRedis" BOOLEAN NOT NULL DEFAULT false,
"enableRabbitmq" BOOLEAN NOT NULL DEFAULT false,
"enableElasticsearch" BOOLEAN NOT NULL DEFAULT false,
"billingCycle" VARCHAR,
"expiresAt" TIMESTAMPTZ NOT NULL,
"consumedAt" TIMESTAMPTZ,
"appliedApplicationId" VARCHAR,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX IF NOT EXISTS idx_resource_credits_user_active
ON resource_credits ("userId", "expiresAt")
WHERE "consumedAt" IS NULL;