22359be40e
Close billing, tenancy, migration, build, and CI/CD gaps identified in the audit: wallet/gateway guards, full-UUID namespaces, idempotent migrations with base schema, stateful service stability, safer Dockerfiles/git builds, and platform chart hardening (Redis auth, RollingUpdate, backups, Swagger off). Co-authored-by: Cursor <cursoragent@cursor.com>
1639 lines
46 KiB
SQL
1639 lines
46 KiB
SQL
-- 000_base_schema.sql — greenfield base schema (generated from TypeORM entities).
|
|
-- Auto-generated by scripts/generate-base-schema.mjs. Do not edit by hand.
|
|
-- Incremental migrations (001+) run afterwards on top of this schema.
|
|
|
|
--
|
|
-- PostgreSQL database dump
|
|
--
|
|
|
|
|
|
-- Dumped from database version 16.13
|
|
-- Dumped by pg_dump version 16.13
|
|
|
|
SET statement_timeout = 0;
|
|
SET lock_timeout = 0;
|
|
SET idle_in_transaction_session_timeout = 0;
|
|
SET client_encoding = 'UTF8';
|
|
SET standard_conforming_strings = on;
|
|
SET check_function_bodies = false;
|
|
SET xmloption = content;
|
|
SET client_min_messages = warning;
|
|
SET row_security = off;
|
|
|
|
--
|
|
-- Name: public; Type: SCHEMA; Schema: -; Owner: -
|
|
--
|
|
|
|
-- *not* creating schema, since initdb creates it
|
|
|
|
|
|
--
|
|
-- Name: SCHEMA public; Type: COMMENT; Schema: -; Owner: -
|
|
--
|
|
|
|
COMMENT ON SCHEMA public IS '';
|
|
|
|
|
|
--
|
|
-- Name: uuid-ossp; Type: EXTENSION; Schema: -; Owner: -
|
|
--
|
|
|
|
CREATE EXTENSION IF NOT EXISTS "uuid-ossp" WITH SCHEMA public;
|
|
|
|
|
|
--
|
|
-- Name: EXTENSION "uuid-ossp"; Type: COMMENT; Schema: -; Owner: -
|
|
--
|
|
|
|
COMMENT ON EXTENSION "uuid-ossp" IS 'generate universally unique identifiers (UUIDs)';
|
|
|
|
|
|
--
|
|
-- Name: addon_rates_resourcetype_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.addon_rates_resourcetype_enum AS ENUM (
|
|
'base_fee',
|
|
'cpu_per_core',
|
|
'memory_per_gb',
|
|
'storage_per_gb',
|
|
'database_addon',
|
|
'redis_addon',
|
|
'rabbitmq_addon',
|
|
'elasticsearch_addon',
|
|
'custom_domain_addon'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: applications_billingcycle_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.applications_billingcycle_enum AS ENUM (
|
|
'hourly',
|
|
'monthly',
|
|
'yearly'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: applications_customdomainstatus_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.applications_customdomainstatus_enum AS ENUM (
|
|
'none',
|
|
'pending_dns',
|
|
'verified'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: applications_databasetype_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.applications_databasetype_enum AS ENUM (
|
|
'mysql',
|
|
'postgresql',
|
|
'mongodb',
|
|
'mariadb',
|
|
'none'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: applications_lifecyclestatus_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.applications_lifecyclestatus_enum AS ENUM (
|
|
'active',
|
|
'suspended',
|
|
'pending_deletion',
|
|
'docked',
|
|
'deleted'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: applications_runtime_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.applications_runtime_enum AS ENUM (
|
|
'nodejs',
|
|
'laravel',
|
|
'wordpress',
|
|
'go',
|
|
'php',
|
|
'python',
|
|
'django',
|
|
'dotnet'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: clusters_status_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.clusters_status_enum AS ENUM (
|
|
'active',
|
|
'inactive',
|
|
'maintenance'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: deployments_status_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.deployments_status_enum AS ENUM (
|
|
'pending',
|
|
'building',
|
|
'build_failed',
|
|
'deploying',
|
|
'running',
|
|
'failed',
|
|
'cancelled',
|
|
'stopped',
|
|
'deleting'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: invoices_paymentmethod_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.invoices_paymentmethod_enum AS ENUM (
|
|
'wallet',
|
|
'gateway',
|
|
'mixed'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: invoices_reason_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.invoices_reason_enum AS ENUM (
|
|
'deploy',
|
|
'renewal',
|
|
'upgrade',
|
|
'wallet_topup',
|
|
'manual'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: invoices_status_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.invoices_status_enum AS ENUM (
|
|
'draft',
|
|
'issued',
|
|
'partially_paid',
|
|
'paid',
|
|
'void',
|
|
'failed'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: optional_service_profiles_service_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.optional_service_profiles_service_enum AS ENUM (
|
|
'redis',
|
|
'rabbitmq',
|
|
'elasticsearch'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: optional_service_rates_resourcetype_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.optional_service_rates_resourcetype_enum AS ENUM (
|
|
'base_fee',
|
|
'cpu_per_core',
|
|
'memory_per_gb',
|
|
'storage_per_gb',
|
|
'database_addon',
|
|
'redis_addon',
|
|
'rabbitmq_addon',
|
|
'elasticsearch_addon',
|
|
'custom_domain_addon'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: optional_service_rates_service_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.optional_service_rates_service_enum AS ENUM (
|
|
'redis',
|
|
'rabbitmq',
|
|
'elasticsearch'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: pricing_rates_resourcetype_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.pricing_rates_resourcetype_enum AS ENUM (
|
|
'base_fee',
|
|
'cpu_per_core',
|
|
'memory_per_gb',
|
|
'storage_per_gb',
|
|
'database_addon',
|
|
'redis_addon',
|
|
'rabbitmq_addon',
|
|
'elasticsearch_addon',
|
|
'custom_domain_addon'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: pricing_rates_runtime_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.pricing_rates_runtime_enum AS ENUM (
|
|
'nodejs',
|
|
'laravel',
|
|
'wordpress',
|
|
'go',
|
|
'php',
|
|
'python',
|
|
'django',
|
|
'dotnet'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: pricing_rules_resourcetype_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.pricing_rules_resourcetype_enum AS ENUM (
|
|
'base_fee',
|
|
'cpu_per_core',
|
|
'memory_per_gb',
|
|
'storage_per_gb',
|
|
'database_addon',
|
|
'redis_addon',
|
|
'rabbitmq_addon',
|
|
'elasticsearch_addon',
|
|
'custom_domain_addon'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: resource_credits_billingcycle_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.resource_credits_billingcycle_enum AS ENUM (
|
|
'hourly',
|
|
'monthly',
|
|
'yearly'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: resource_credits_databasetype_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.resource_credits_databasetype_enum AS ENUM (
|
|
'mysql',
|
|
'postgresql',
|
|
'mongodb',
|
|
'mariadb',
|
|
'none'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: resource_credits_runtime_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.resource_credits_runtime_enum AS ENUM (
|
|
'nodejs',
|
|
'laravel',
|
|
'wordpress',
|
|
'go',
|
|
'php',
|
|
'python',
|
|
'django',
|
|
'dotnet'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: service_access_grants_status_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.service_access_grants_status_enum AS ENUM (
|
|
'active',
|
|
'expired',
|
|
'revoked'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: service_access_grants_target_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.service_access_grants_target_enum AS ENUM (
|
|
'database',
|
|
'redis',
|
|
'rabbitmq_amqp',
|
|
'rabbitmq_management'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: service_plans_billingcycle_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.service_plans_billingcycle_enum AS ENUM (
|
|
'hourly',
|
|
'monthly',
|
|
'yearly'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: service_plans_runtime_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.service_plans_runtime_enum AS ENUM (
|
|
'nodejs',
|
|
'laravel',
|
|
'wordpress',
|
|
'go',
|
|
'php',
|
|
'python',
|
|
'django',
|
|
'dotnet'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: snapshots_status_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.snapshots_status_enum AS ENUM (
|
|
'in_progress',
|
|
'completed',
|
|
'failed'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: snapshots_type_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.snapshots_type_enum AS ENUM (
|
|
'pre_deploy',
|
|
'manual'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: ticket_messages_senderrole_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.ticket_messages_senderrole_enum AS ENUM (
|
|
'user',
|
|
'admin',
|
|
'technical',
|
|
'sales'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: tickets_department_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.tickets_department_enum AS ENUM (
|
|
'technical',
|
|
'sales'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: tickets_priority_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.tickets_priority_enum AS ENUM (
|
|
'low',
|
|
'medium',
|
|
'high'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: tickets_status_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.tickets_status_enum AS ENUM (
|
|
'open',
|
|
'answered',
|
|
'waiting',
|
|
'closed'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: users_role_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.users_role_enum AS ENUM (
|
|
'user',
|
|
'admin',
|
|
'technical',
|
|
'sales'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: verification_codes_purpose_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.verification_codes_purpose_enum AS ENUM (
|
|
'login',
|
|
'change_phone'
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: wallet_transactions_type_enum; Type: TYPE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TYPE public.wallet_transactions_type_enum AS ENUM (
|
|
'charge',
|
|
'deduction',
|
|
'refund',
|
|
'gateway_payment'
|
|
);
|
|
|
|
|
|
SET default_tablespace = '';
|
|
|
|
SET default_table_access_method = heap;
|
|
|
|
--
|
|
-- Name: addon_rates; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.addon_rates (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
"resourceType" public.addon_rates_resourcetype_enum NOT NULL,
|
|
"hourlyPrice" numeric(12,2) DEFAULT '0'::numeric NOT NULL,
|
|
"monthlyPrice" numeric(12,2) DEFAULT '0'::numeric NOT NULL,
|
|
"yearlyPrice" numeric(12,2) DEFAULT '0'::numeric NOT NULL,
|
|
"isActive" boolean DEFAULT true NOT NULL,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: application_migration_events; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.application_migration_events (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
"migrationId" uuid NOT NULL,
|
|
step character varying NOT NULL,
|
|
level character varying DEFAULT 'info'::character varying NOT NULL,
|
|
message character varying NOT NULL,
|
|
metadata jsonb,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: application_migration_jobs; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.application_migration_jobs (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
"applicationId" uuid NOT NULL,
|
|
"requestedBy" character varying NOT NULL,
|
|
"sourceClusterId" uuid NOT NULL,
|
|
"targetClusterId" uuid NOT NULL,
|
|
status character varying DEFAULT 'queued'::character varying NOT NULL,
|
|
attempts integer DEFAULT 0 NOT NULL,
|
|
"maxAttempts" integer DEFAULT 3 NOT NULL,
|
|
"currentStep" character varying,
|
|
"errorMessage" character varying,
|
|
metadata jsonb,
|
|
"startedAt" timestamp with time zone,
|
|
"completedAt" timestamp with time zone,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: applications; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.applications (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
name character varying NOT NULL,
|
|
"productType" character varying DEFAULT 'application'::character varying NOT NULL,
|
|
description character varying,
|
|
runtime public.applications_runtime_enum NOT NULL,
|
|
"databaseType" public.applications_databasetype_enum DEFAULT 'none'::public.applications_databasetype_enum NOT NULL,
|
|
"runtimeVersion" character varying,
|
|
"phpVersion" character varying,
|
|
"dbVersion" character varying,
|
|
"dbUsername" character varying,
|
|
"dbPassword" character varying,
|
|
"dbStorageSize" character varying DEFAULT '1Gi'::character varying,
|
|
"appStorageSize" character varying DEFAULT '2Gi'::character varying,
|
|
"enableRedis" boolean DEFAULT false NOT NULL,
|
|
"redisVersion" character varying DEFAULT '7.2'::character varying,
|
|
"enableRabbitmq" boolean DEFAULT false NOT NULL,
|
|
"rabbitmqVersion" character varying DEFAULT '3.13'::character varying,
|
|
"enableElasticsearch" boolean DEFAULT false NOT NULL,
|
|
"elasticsearchVersion" character varying DEFAULT '8.12'::character varying,
|
|
"logPaths" jsonb,
|
|
"optionalServiceResources" jsonb,
|
|
"gitUrl" character varying,
|
|
"gitToken" character varying,
|
|
"gitBranch" character varying,
|
|
"codePath" character varying,
|
|
"dbDumpPath" character varying,
|
|
"envVars" jsonb,
|
|
"cpuRequest" character varying DEFAULT '100m'::character varying NOT NULL,
|
|
"cpuLimit" character varying DEFAULT '500m'::character varying NOT NULL,
|
|
"memoryRequest" character varying DEFAULT '128Mi'::character varying NOT NULL,
|
|
"memoryLimit" character varying DEFAULT '512Mi'::character varying NOT NULL,
|
|
replicas integer DEFAULT 1 NOT NULL,
|
|
port integer DEFAULT 3000 NOT NULL,
|
|
"userId" uuid NOT NULL,
|
|
"clusterId" uuid,
|
|
"poolId" uuid,
|
|
"latestImageTag" character varying,
|
|
subdomain character varying,
|
|
"customDomain" character varying,
|
|
"customDomainStatus" public.applications_customdomainstatus_enum DEFAULT 'none'::public.applications_customdomainstatus_enum NOT NULL,
|
|
"customDomainVerifiedAt" timestamp with time zone,
|
|
"planId" character varying,
|
|
"billingCycle" public.applications_billingcycle_enum,
|
|
"lifecycleStatus" public.applications_lifecyclestatus_enum DEFAULT 'active'::public.applications_lifecyclestatus_enum NOT NULL,
|
|
"planExpiresAt" timestamp with time zone,
|
|
"suspendedAt" timestamp with time zone,
|
|
"suspendedReplicas" jsonb,
|
|
"scheduledDeletionAt" timestamp with time zone,
|
|
"dockedAt" timestamp with time zone,
|
|
"dockSnapshotId" character varying,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: audit_logs; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.audit_logs (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
action character varying NOT NULL,
|
|
"actorUserId" uuid NOT NULL,
|
|
"targetUserId" uuid,
|
|
metadata jsonb,
|
|
ip character varying,
|
|
"userAgent" character varying,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: cluster_allocation_logs; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.cluster_allocation_logs (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
"applicationId" uuid,
|
|
"userId" character varying NOT NULL,
|
|
"poolId" uuid,
|
|
"selectedClusterId" uuid,
|
|
strategy character varying DEFAULT 'weighted-resource'::character varying NOT NULL,
|
|
"estimatedRequest" jsonb,
|
|
"candidateScores" jsonb,
|
|
"rejectionReasons" jsonb,
|
|
status character varying DEFAULT 'success'::character varying NOT NULL,
|
|
message character varying,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: cluster_health; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.cluster_health (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
"clusterId" uuid NOT NULL,
|
|
status character varying DEFAULT 'unknown'::character varying NOT NULL,
|
|
"readyNodes" integer DEFAULT 0 NOT NULL,
|
|
"nodeCount" integer DEFAULT 0 NOT NULL,
|
|
"cpuAllocatable" character varying,
|
|
"memoryAllocatable" character varying,
|
|
"podCount" integer DEFAULT 0 NOT NULL,
|
|
"appCount" integer DEFAULT 0 NOT NULL,
|
|
message character varying,
|
|
resources jsonb,
|
|
"checkedAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: cluster_pools; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.cluster_pools (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
name character varying NOT NULL,
|
|
description character varying,
|
|
strategy character varying DEFAULT 'weighted-resource'::character varying NOT NULL,
|
|
"clusterIds" jsonb DEFAULT '[]'::jsonb NOT NULL,
|
|
"isActive" boolean DEFAULT true NOT NULL,
|
|
"isDefault" boolean DEFAULT false NOT NULL,
|
|
priority integer DEFAULT 100 NOT NULL,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: clusters; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.clusters (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
name character varying NOT NULL,
|
|
description character varying,
|
|
status public.clusters_status_enum DEFAULT 'active'::public.clusters_status_enum NOT NULL,
|
|
kubeconfig text NOT NULL,
|
|
"apiServer" character varying NOT NULL,
|
|
region character varying,
|
|
weight integer DEFAULT 1 NOT NULL,
|
|
tags jsonb DEFAULT '[]'::jsonb NOT NULL,
|
|
"healthStatus" character varying DEFAULT 'unknown'::character varying NOT NULL,
|
|
"lastHealthCheckedAt" timestamp with time zone,
|
|
"healthMessage" character varying,
|
|
"availableResources" jsonb,
|
|
provider character varying,
|
|
"isDefault" boolean DEFAULT false NOT NULL,
|
|
"defaultCpuLimit" character varying DEFAULT '4'::character varying NOT NULL,
|
|
"defaultMemoryLimit" character varying DEFAULT '8Gi'::character varying NOT NULL,
|
|
"maxAppsPerUser" integer DEFAULT 10 NOT NULL,
|
|
metadata jsonb,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: deployments; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.deployments (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
status public.deployments_status_enum DEFAULT 'pending'::public.deployments_status_enum NOT NULL,
|
|
"imageTag" character varying NOT NULL,
|
|
version character varying,
|
|
"k8sResources" jsonb,
|
|
"buildLog" text,
|
|
"deployLog" text,
|
|
"previewSubdomain" character varying(63),
|
|
"errorMessage" character varying,
|
|
"applicationId" uuid NOT NULL,
|
|
"triggeredBy" character varying NOT NULL,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"finishedAt" timestamp without time zone
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: discount_redemptions; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.discount_redemptions (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
"discountId" uuid NOT NULL,
|
|
"userId" character varying NOT NULL,
|
|
"invoiceId" character varying,
|
|
amount numeric(14,2) DEFAULT '0'::numeric NOT NULL,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: discounts; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.discounts (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
code character varying NOT NULL,
|
|
name character varying NOT NULL,
|
|
description character varying,
|
|
"percentOff" integer NOT NULL,
|
|
services jsonb DEFAULT '[]'::jsonb NOT NULL,
|
|
"isPublic" boolean DEFAULT true NOT NULL,
|
|
"allowedUserIds" jsonb DEFAULT '[]'::jsonb NOT NULL,
|
|
"maxUses" integer,
|
|
"maxUsesPerUser" integer,
|
|
"usedCount" integer DEFAULT 0 NOT NULL,
|
|
"startsAt" timestamp with time zone,
|
|
"endsAt" timestamp with time zone,
|
|
"isActive" boolean DEFAULT true NOT NULL,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: invoice_lines; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.invoice_lines (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
"invoiceId" uuid NOT NULL,
|
|
label character varying NOT NULL,
|
|
description character varying,
|
|
quantity integer DEFAULT 1 NOT NULL,
|
|
"unitAmount" numeric(14,2) DEFAULT '0'::numeric NOT NULL,
|
|
amount numeric(14,2) DEFAULT '0'::numeric NOT NULL,
|
|
metadata jsonb,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: invoices; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.invoices (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
"invoiceNumber" character varying NOT NULL,
|
|
"userId" uuid NOT NULL,
|
|
"applicationId" uuid,
|
|
reason public.invoices_reason_enum DEFAULT 'manual'::public.invoices_reason_enum NOT NULL,
|
|
status public.invoices_status_enum DEFAULT 'issued'::public.invoices_status_enum NOT NULL,
|
|
"paymentMethod" public.invoices_paymentmethod_enum,
|
|
subtotal numeric(14,2) DEFAULT '0'::numeric NOT NULL,
|
|
"discountAmount" numeric(14,2) DEFAULT '0'::numeric NOT NULL,
|
|
"discountCode" character varying,
|
|
total numeric(14,2) DEFAULT '0'::numeric NOT NULL,
|
|
"paidAmount" numeric(14,2) DEFAULT '0'::numeric NOT NULL,
|
|
"dueAmount" numeric(14,2) DEFAULT '0'::numeric NOT NULL,
|
|
"dueDate" timestamp with time zone,
|
|
"paidAt" timestamp with time zone,
|
|
"gatewayTrackingCode" character varying,
|
|
"gatewayReference" character varying,
|
|
"adminNote" character varying,
|
|
"statusReason" character varying,
|
|
metadata jsonb,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: optional_service_profiles; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.optional_service_profiles (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
service public.optional_service_profiles_service_enum NOT NULL,
|
|
"cpuRequest" character varying,
|
|
"memoryRequest" character varying,
|
|
"cpuLimit" character varying DEFAULT '200m'::character varying NOT NULL,
|
|
"memoryLimit" character varying DEFAULT '256Mi'::character varying NOT NULL,
|
|
"storageGi" numeric(10,2) DEFAULT '1'::numeric NOT NULL,
|
|
"logShipperCpuLimit" character varying,
|
|
"logShipperMemoryLimit" character varying,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: optional_service_rates; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.optional_service_rates (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
service public.optional_service_rates_service_enum NOT NULL,
|
|
"resourceType" public.optional_service_rates_resourcetype_enum NOT NULL,
|
|
"hourlyPrice" numeric(12,2) DEFAULT '0'::numeric NOT NULL,
|
|
"monthlyPrice" numeric(12,2) DEFAULT '0'::numeric NOT NULL,
|
|
"yearlyPrice" numeric(12,2) DEFAULT '0'::numeric NOT NULL,
|
|
"isActive" boolean DEFAULT true NOT NULL,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: platform_settings; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.platform_settings (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
key character varying NOT NULL,
|
|
value text NOT NULL,
|
|
description character varying,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: pricing_rates; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.pricing_rates (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
runtime public.pricing_rates_runtime_enum NOT NULL,
|
|
"resourceType" public.pricing_rates_resourcetype_enum NOT NULL,
|
|
"hourlyPrice" numeric(12,2) DEFAULT '0'::numeric NOT NULL,
|
|
"monthlyPrice" numeric(12,2) DEFAULT '0'::numeric NOT NULL,
|
|
"yearlyPrice" numeric(12,2) DEFAULT '0'::numeric NOT NULL,
|
|
"isActive" boolean DEFAULT true NOT NULL,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: pricing_rules; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.pricing_rules (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
"resourceType" public.pricing_rules_resourcetype_enum NOT NULL,
|
|
"unitPrice" numeric(12,2) NOT NULL,
|
|
description character varying,
|
|
"planId" uuid NOT NULL,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: resource_credits; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.resource_credits (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
"userId" uuid NOT NULL,
|
|
"sourceAppName" character varying,
|
|
"productType" character varying DEFAULT 'application'::character varying NOT NULL,
|
|
runtime public.resource_credits_runtime_enum NOT NULL,
|
|
"databaseType" public.resource_credits_databasetype_enum NOT NULL,
|
|
"cpuLimit" character varying NOT NULL,
|
|
"memoryLimit" character varying NOT NULL,
|
|
replicas integer DEFAULT 1 NOT NULL,
|
|
"dbStorageSize" character varying,
|
|
"appStorageSize" character varying,
|
|
"enableRedis" boolean DEFAULT false NOT NULL,
|
|
"enableRabbitmq" boolean DEFAULT false NOT NULL,
|
|
"enableElasticsearch" boolean DEFAULT false NOT NULL,
|
|
"billingCycle" public.resource_credits_billingcycle_enum,
|
|
"expiresAt" timestamp with time zone NOT NULL,
|
|
"consumedAt" timestamp with time zone,
|
|
"appliedApplicationId" character varying,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: service_access_grants; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.service_access_grants (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
"applicationId" uuid NOT NULL,
|
|
"userId" character varying NOT NULL,
|
|
"clusterId" character varying NOT NULL,
|
|
namespace character varying NOT NULL,
|
|
target public.service_access_grants_target_enum NOT NULL,
|
|
"nodePort" integer NOT NULL,
|
|
"targetPort" integer NOT NULL,
|
|
host character varying NOT NULL,
|
|
"k8sServiceName" character varying NOT NULL,
|
|
status public.service_access_grants_status_enum DEFAULT 'active'::public.service_access_grants_status_enum NOT NULL,
|
|
persistent boolean DEFAULT false NOT NULL,
|
|
"expiresAt" timestamp with time zone NOT NULL,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: service_plans; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.service_plans (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
name character varying NOT NULL,
|
|
runtime public.service_plans_runtime_enum NOT NULL,
|
|
description character varying,
|
|
"billingCycle" public.service_plans_billingcycle_enum NOT NULL,
|
|
"isActive" boolean DEFAULT true NOT NULL,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: snapshots; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.snapshots (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
type public.snapshots_type_enum DEFAULT 'manual'::public.snapshots_type_enum NOT NULL,
|
|
status public.snapshots_status_enum DEFAULT 'in_progress'::public.snapshots_status_enum NOT NULL,
|
|
label character varying,
|
|
"appArchivePath" character varying,
|
|
"wpContentArchivePath" character varying,
|
|
"imageTag" character varying,
|
|
"dbDumpPath" character varying,
|
|
"hasDatabase" boolean DEFAULT false NOT NULL,
|
|
"appArchiveSize" bigint,
|
|
"dbDumpSize" bigint,
|
|
"wpContentSize" bigint,
|
|
"errorMessage" character varying,
|
|
progress integer DEFAULT 0 NOT NULL,
|
|
"applicationId" uuid NOT NULL,
|
|
"createdBy" character varying NOT NULL,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: ticket_messages; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.ticket_messages (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
message text NOT NULL,
|
|
"ticketId" uuid NOT NULL,
|
|
"senderId" uuid NOT NULL,
|
|
"senderRole" public.ticket_messages_senderrole_enum NOT NULL,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: tickets; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.tickets (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
subject character varying NOT NULL,
|
|
department public.tickets_department_enum NOT NULL,
|
|
status public.tickets_status_enum DEFAULT 'open'::public.tickets_status_enum NOT NULL,
|
|
priority public.tickets_priority_enum DEFAULT 'medium'::public.tickets_priority_enum NOT NULL,
|
|
"userId" uuid NOT NULL,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"closedAt" timestamp without time zone
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: users; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.users (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
phone character varying,
|
|
email character varying,
|
|
"phoneVerified" boolean DEFAULT false NOT NULL,
|
|
password character varying NOT NULL,
|
|
"firstName" character varying NOT NULL,
|
|
"lastName" character varying NOT NULL,
|
|
role public.users_role_enum DEFAULT 'user'::public.users_role_enum NOT NULL,
|
|
"isActive" boolean DEFAULT true NOT NULL,
|
|
namespace character varying,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: verification_codes; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.verification_codes (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
"userId" uuid NOT NULL,
|
|
purpose public.verification_codes_purpose_enum NOT NULL,
|
|
destination character varying NOT NULL,
|
|
"codeHash" character varying NOT NULL,
|
|
"expiresAt" timestamp with time zone NOT NULL,
|
|
attempts integer DEFAULT 0 NOT NULL,
|
|
"consumedAt" timestamp with time zone,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: wallet_transactions; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.wallet_transactions (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
type public.wallet_transactions_type_enum NOT NULL,
|
|
amount numeric(14,2) NOT NULL,
|
|
"balanceAfter" numeric(14,2) NOT NULL,
|
|
description character varying,
|
|
"applicationId" character varying,
|
|
"invoiceId" uuid,
|
|
"walletId" uuid NOT NULL,
|
|
"gatewayTrackingCode" character varying,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: wallets; Type: TABLE; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE TABLE public.wallets (
|
|
id uuid DEFAULT public.uuid_generate_v4() NOT NULL,
|
|
balance numeric(14,2) DEFAULT '0'::numeric NOT NULL,
|
|
"userId" uuid NOT NULL,
|
|
"createdAt" timestamp without time zone DEFAULT now() NOT NULL,
|
|
"updatedAt" timestamp without time zone DEFAULT now() NOT NULL
|
|
);
|
|
|
|
|
|
--
|
|
-- Name: application_migration_jobs PK_130c380307e6aec30012c92e932; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.application_migration_jobs
|
|
ADD CONSTRAINT "PK_130c380307e6aec30012c92e932" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: verification_codes PK_18741b6b8bf1680dbf5057421d7; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.verification_codes
|
|
ADD CONSTRAINT "PK_18741b6b8bf1680dbf5057421d7" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: audit_logs PK_1bb179d048bbc581caa3b013439; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.audit_logs
|
|
ADD CONSTRAINT "PK_1bb179d048bbc581caa3b013439" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: deployments PK_1e5627acb3c950deb83fe98fc48; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.deployments
|
|
ADD CONSTRAINT "PK_1e5627acb3c950deb83fe98fc48" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: optional_service_profiles PK_2625f60eb9be17174299de23f47; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.optional_service_profiles
|
|
ADD CONSTRAINT "PK_2625f60eb9be17174299de23f47" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: platform_settings PK_2934aeb70ec285196dcab4a2e96; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.platform_settings
|
|
ADD CONSTRAINT "PK_2934aeb70ec285196dcab4a2e96" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: discount_redemptions PK_2efe685154f7c7deacaf6f0ef63; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.discount_redemptions
|
|
ADD CONSTRAINT "PK_2efe685154f7c7deacaf6f0ef63" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: tickets PK_343bc942ae261cf7a1377f48fd0; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.tickets
|
|
ADD CONSTRAINT "PK_343bc942ae261cf7a1377f48fd0" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: cluster_allocation_logs PK_34d1148bb1df92decfcdc7cab87; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.cluster_allocation_logs
|
|
ADD CONSTRAINT "PK_34d1148bb1df92decfcdc7cab87" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: ticket_messages PK_37beb692dedf7eccb4e519ccec1; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.ticket_messages
|
|
ADD CONSTRAINT "PK_37beb692dedf7eccb4e519ccec1" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: invoice_lines PK_3d18eb48142b916f581f0c21a65; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.invoice_lines
|
|
ADD CONSTRAINT "PK_3d18eb48142b916f581f0c21a65" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: wallet_transactions PK_5120f131bde2cda940ec1a621db; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.wallet_transactions
|
|
ADD CONSTRAINT "PK_5120f131bde2cda940ec1a621db" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: clusters PK_56c8e201f375e1e961dcdd6831c; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.clusters
|
|
ADD CONSTRAINT "PK_56c8e201f375e1e961dcdd6831c" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: invoices PK_668cef7c22a427fd822cc1be3ce; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.invoices
|
|
ADD CONSTRAINT "PK_668cef7c22a427fd822cc1be3ce" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: discounts PK_66c522004212dc814d6e2f14ecc; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.discounts
|
|
ADD CONSTRAINT "PK_66c522004212dc814d6e2f14ecc" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: service_plans PK_679a9e435f1af95a94d9749a087; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.service_plans
|
|
ADD CONSTRAINT "PK_679a9e435f1af95a94d9749a087" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: resource_credits PK_6a1f7bee5bd45667c08a63d9e3c; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.resource_credits
|
|
ADD CONSTRAINT "PK_6a1f7bee5bd45667c08a63d9e3c" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: pricing_rates PK_6b3ac518f3abafc7d0e1b6bb449; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.pricing_rates
|
|
ADD CONSTRAINT "PK_6b3ac518f3abafc7d0e1b6bb449" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: addon_rates PK_817008cdfd7d2040209665de3cf; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.addon_rates
|
|
ADD CONSTRAINT "PK_817008cdfd7d2040209665de3cf" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: wallets PK_8402e5df5a30a229380e83e4f7e; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.wallets
|
|
ADD CONSTRAINT "PK_8402e5df5a30a229380e83e4f7e" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: applications PK_938c0a27255637bde919591888f; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.applications
|
|
ADD CONSTRAINT "PK_938c0a27255637bde919591888f" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: users PK_a3ffb1c0c8416b9fc6f907b7433; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.users
|
|
ADD CONSTRAINT "PK_a3ffb1c0c8416b9fc6f907b7433" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: cluster_health PK_a619d68317e11de0cdc7769936c; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.cluster_health
|
|
ADD CONSTRAINT "PK_a619d68317e11de0cdc7769936c" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: service_access_grants PK_ba880e7036fb12629d2bb20813b; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.service_access_grants
|
|
ADD CONSTRAINT "PK_ba880e7036fb12629d2bb20813b" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: application_migration_events PK_cbbcd35db024c6ce5282dc4b826; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.application_migration_events
|
|
ADD CONSTRAINT "PK_cbbcd35db024c6ce5282dc4b826" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: cluster_pools PK_cd7c2f36783be8d628956f41734; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.cluster_pools
|
|
ADD CONSTRAINT "PK_cd7c2f36783be8d628956f41734" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: optional_service_rates PK_dde26d2c02f198afe455543e16c; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.optional_service_rates
|
|
ADD CONSTRAINT "PK_dde26d2c02f198afe455543e16c" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: snapshots PK_f5661b5fd4224d23e26a631986b; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.snapshots
|
|
ADD CONSTRAINT "PK_f5661b5fd4224d23e26a631986b" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: pricing_rules PK_fda27bb8db4630894decda61ff6; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.pricing_rules
|
|
ADD CONSTRAINT "PK_fda27bb8db4630894decda61ff6" PRIMARY KEY (id);
|
|
|
|
|
|
--
|
|
-- Name: wallets UQ_2ecdb33f23e9a6fc392025c0b97; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.wallets
|
|
ADD CONSTRAINT "UQ_2ecdb33f23e9a6fc392025c0b97" UNIQUE ("userId");
|
|
|
|
|
|
--
|
|
-- Name: platform_settings UQ_5d9031e30fac3ec3ec8b9602e17; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.platform_settings
|
|
ADD CONSTRAINT "UQ_5d9031e30fac3ec3ec8b9602e17" UNIQUE (key);
|
|
|
|
|
|
--
|
|
-- Name: optional_service_profiles UQ_63c79ca1dc0b57933b800469504; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.optional_service_profiles
|
|
ADD CONSTRAINT "UQ_63c79ca1dc0b57933b800469504" UNIQUE (service);
|
|
|
|
|
|
--
|
|
-- Name: pricing_rates UQ_8323897b5a47d20ef92896dc5a8; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.pricing_rates
|
|
ADD CONSTRAINT "UQ_8323897b5a47d20ef92896dc5a8" UNIQUE (runtime, "resourceType");
|
|
|
|
|
|
--
|
|
-- Name: discounts UQ_8c7cc2340e9ea0fc5a246e63749; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.discounts
|
|
ADD CONSTRAINT "UQ_8c7cc2340e9ea0fc5a246e63749" UNIQUE (code);
|
|
|
|
|
|
--
|
|
-- Name: users UQ_97672ac88f789774dd47f7c8be3; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.users
|
|
ADD CONSTRAINT "UQ_97672ac88f789774dd47f7c8be3" UNIQUE (email);
|
|
|
|
|
|
--
|
|
-- Name: users UQ_a000cca60bcf04454e727699490; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.users
|
|
ADD CONSTRAINT "UQ_a000cca60bcf04454e727699490" UNIQUE (phone);
|
|
|
|
|
|
--
|
|
-- Name: invoices UQ_bf8e0f9dd4558ef209ec111782d; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.invoices
|
|
ADD CONSTRAINT "UQ_bf8e0f9dd4558ef209ec111782d" UNIQUE ("invoiceNumber");
|
|
|
|
|
|
--
|
|
-- Name: optional_service_rates UQ_da71e6eb43a191e589c4e1d32f6; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.optional_service_rates
|
|
ADD CONSTRAINT "UQ_da71e6eb43a191e589c4e1d32f6" UNIQUE (service, "resourceType");
|
|
|
|
|
|
--
|
|
-- Name: addon_rates UQ_ef90e5f423c8ff2fd3b321763e8; Type: CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.addon_rates
|
|
ADD CONSTRAINT "UQ_ef90e5f423c8ff2fd3b321763e8" UNIQUE ("resourceType");
|
|
|
|
|
|
--
|
|
-- Name: IDX_43facb440ecfb2acadcf2922b5; Type: INDEX; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE INDEX "IDX_43facb440ecfb2acadcf2922b5" ON public.service_access_grants USING btree ("applicationId", target, status);
|
|
|
|
|
|
--
|
|
-- Name: IDX_5b7fbc8045a0654e5f8db27dc5; Type: INDEX; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE INDEX "IDX_5b7fbc8045a0654e5f8db27dc5" ON public.audit_logs USING btree ("targetUserId");
|
|
|
|
|
|
--
|
|
-- Name: IDX_b455a8c210f79a873760a92819; Type: INDEX; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE INDEX "IDX_b455a8c210f79a873760a92819" ON public.verification_codes USING btree ("userId", purpose);
|
|
|
|
|
|
--
|
|
-- Name: IDX_c1e88bb93860db181f5b21a306; Type: INDEX; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE INDEX "IDX_c1e88bb93860db181f5b21a306" ON public.discount_redemptions USING btree ("discountId", "userId");
|
|
|
|
|
|
--
|
|
-- Name: IDX_e36d23e1e7cf81ea77758bef79; Type: INDEX; Schema: public; Owner: -
|
|
--
|
|
|
|
CREATE INDEX "IDX_e36d23e1e7cf81ea77758bef79" ON public.audit_logs USING btree ("actorUserId");
|
|
|
|
|
|
--
|
|
-- Name: application_migration_jobs FK_12568b7d01ef97d05da755833f3; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.application_migration_jobs
|
|
ADD CONSTRAINT "FK_12568b7d01ef97d05da755833f3" FOREIGN KEY ("applicationId") REFERENCES public.applications(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: wallets FK_2ecdb33f23e9a6fc392025c0b97; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.wallets
|
|
ADD CONSTRAINT "FK_2ecdb33f23e9a6fc392025c0b97" FOREIGN KEY ("userId") REFERENCES public.users(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: cluster_allocation_logs FK_3b1bba8052f0504c2ff400f70a4; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.cluster_allocation_logs
|
|
ADD CONSTRAINT "FK_3b1bba8052f0504c2ff400f70a4" FOREIGN KEY ("selectedClusterId") REFERENCES public.clusters(id) ON DELETE SET NULL;
|
|
|
|
|
|
--
|
|
-- Name: cluster_allocation_logs FK_3ef9df9c9317fab60fdcb5f581b; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.cluster_allocation_logs
|
|
ADD CONSTRAINT "FK_3ef9df9c9317fab60fdcb5f581b" FOREIGN KEY ("applicationId") REFERENCES public.applications(id) ON DELETE SET NULL;
|
|
|
|
|
|
--
|
|
-- Name: cluster_allocation_logs FK_44764afc850c4b3a8c62547c2a9; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.cluster_allocation_logs
|
|
ADD CONSTRAINT "FK_44764afc850c4b3a8c62547c2a9" FOREIGN KEY ("poolId") REFERENCES public.cluster_pools(id) ON DELETE SET NULL;
|
|
|
|
|
|
--
|
|
-- Name: service_access_grants FK_48b102a7593a5e76d9fda39dfb0; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.service_access_grants
|
|
ADD CONSTRAINT "FK_48b102a7593a5e76d9fda39dfb0" FOREIGN KEY ("applicationId") REFERENCES public.applications(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: tickets FK_4bb45e096f521845765f657f5c8; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.tickets
|
|
ADD CONSTRAINT "FK_4bb45e096f521845765f657f5c8" FOREIGN KEY ("userId") REFERENCES public.users(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: snapshots FK_5652b27d83628dc5612245d62ce; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.snapshots
|
|
ADD CONSTRAINT "FK_5652b27d83628dc5612245d62ce" FOREIGN KEY ("applicationId") REFERENCES public.applications(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: wallet_transactions FK_581a824e911b9baa6be19cd92fc; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.wallet_transactions
|
|
ADD CONSTRAINT "FK_581a824e911b9baa6be19cd92fc" FOREIGN KEY ("invoiceId") REFERENCES public.invoices(id) ON DELETE SET NULL;
|
|
|
|
|
|
--
|
|
-- Name: invoices FK_875034bdd7f0ac4a726ceffe71e; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.invoices
|
|
ADD CONSTRAINT "FK_875034bdd7f0ac4a726ceffe71e" FOREIGN KEY ("applicationId") REFERENCES public.applications(id) ON DELETE SET NULL;
|
|
|
|
|
|
--
|
|
-- Name: wallet_transactions FK_8a94d9d61a2b05123710b325fbf; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.wallet_transactions
|
|
ADD CONSTRAINT "FK_8a94d9d61a2b05123710b325fbf" FOREIGN KEY ("walletId") REFERENCES public.wallets(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: discount_redemptions FK_8b48303d6ae52e9aa69e2df2259; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.discount_redemptions
|
|
ADD CONSTRAINT "FK_8b48303d6ae52e9aa69e2df2259" FOREIGN KEY ("discountId") REFERENCES public.discounts(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: applications FK_90ad8bec24861de0180f638b9cc; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.applications
|
|
ADD CONSTRAINT "FK_90ad8bec24861de0180f638b9cc" FOREIGN KEY ("userId") REFERENCES public.users(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: application_migration_jobs FK_932030f502543c1116155e7ef14; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.application_migration_jobs
|
|
ADD CONSTRAINT "FK_932030f502543c1116155e7ef14" FOREIGN KEY ("targetClusterId") REFERENCES public.clusters(id) ON DELETE RESTRICT;
|
|
|
|
|
|
--
|
|
-- Name: application_migration_events FK_93b1269e814ba5dfb106d408440; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.application_migration_events
|
|
ADD CONSTRAINT "FK_93b1269e814ba5dfb106d408440" FOREIGN KEY ("migrationId") REFERENCES public.application_migration_jobs(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: verification_codes FK_9a854eeb4598a22d554ecfe6e81; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.verification_codes
|
|
ADD CONSTRAINT "FK_9a854eeb4598a22d554ecfe6e81" FOREIGN KEY ("userId") REFERENCES public.users(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: invoice_lines FK_9f57f31e620fe759b452feb776e; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.invoice_lines
|
|
ADD CONSTRAINT "FK_9f57f31e620fe759b452feb776e" FOREIGN KEY ("invoiceId") REFERENCES public.invoices(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: ticket_messages FK_b01e2a35417efbe04c10828266f; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.ticket_messages
|
|
ADD CONSTRAINT "FK_b01e2a35417efbe04c10828266f" FOREIGN KEY ("ticketId") REFERENCES public.tickets(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: resource_credits FK_c546fd3ecce0091b717b32b0c5b; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.resource_credits
|
|
ADD CONSTRAINT "FK_c546fd3ecce0091b717b32b0c5b" FOREIGN KEY ("userId") REFERENCES public.users(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: cluster_health FK_d38286a989998e278202b43f6c9; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.cluster_health
|
|
ADD CONSTRAINT "FK_d38286a989998e278202b43f6c9" FOREIGN KEY ("clusterId") REFERENCES public.clusters(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: deployments FK_dca3b4d49c7df1e3a6a93b74fd7; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.deployments
|
|
ADD CONSTRAINT "FK_dca3b4d49c7df1e3a6a93b74fd7" FOREIGN KEY ("applicationId") REFERENCES public.applications(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: ticket_messages FK_ddea80824c24d270ef2cb4cb0ba; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.ticket_messages
|
|
ADD CONSTRAINT "FK_ddea80824c24d270ef2cb4cb0ba" FOREIGN KEY ("senderId") REFERENCES public.users(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: pricing_rules FK_f44e102039feebaf8436a606652; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.pricing_rules
|
|
ADD CONSTRAINT "FK_f44e102039feebaf8436a606652" FOREIGN KEY ("planId") REFERENCES public.service_plans(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- Name: application_migration_jobs FK_f68e403cd35eb2b95b1f77355e5; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.application_migration_jobs
|
|
ADD CONSTRAINT "FK_f68e403cd35eb2b95b1f77355e5" FOREIGN KEY ("sourceClusterId") REFERENCES public.clusters(id) ON DELETE RESTRICT;
|
|
|
|
|
|
--
|
|
-- Name: invoices FK_fcbe490dc37a1abf68f19c5ccb9; Type: FK CONSTRAINT; Schema: public; Owner: -
|
|
--
|
|
|
|
ALTER TABLE ONLY public.invoices
|
|
ADD CONSTRAINT "FK_fcbe490dc37a1abf68f19c5ccb9" FOREIGN KEY ("userId") REFERENCES public.users(id) ON DELETE CASCADE;
|
|
|
|
|
|
--
|
|
-- PostgreSQL database dump complete
|
|
--
|
|
|
|
|
|
|
|
|
|
-- Mark superseded legacy pricing migrations as applied (see generator note).
|
|
CREATE TABLE IF NOT EXISTS schema_migrations (filename TEXT PRIMARY KEY, applied_at TIMESTAMPTZ NOT NULL DEFAULT NOW());
|
|
INSERT INTO schema_migrations (filename) VALUES
|
|
('004_pricing_catalog.sql'),
|
|
('005_pricing_catalog_all_runtimes.sql'),
|
|
('006_addon_rate_resources.sql'),
|
|
('007_optional_service_pricing_matrix.sql'),
|
|
('008_application_optional_service_resources.sql'),
|
|
('009_optional_service_deploy_defaults.sql')
|
|
ON CONFLICT (filename) DO NOTHING;
|