68 lines
2.5 KiB
SQL
68 lines
2.5 KiB
SQL
CREATE TABLE IF NOT EXISTS "setup_runs" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"status" text DEFAULT 'not_started' NOT NULL,
|
|
"mode" text DEFAULT 'production' NOT NULL,
|
|
"target_organization_id" text,
|
|
"started_by" text NOT NULL,
|
|
"completed_by" text,
|
|
"started_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"completed_at" timestamp with time zone,
|
|
"last_error" text,
|
|
"metadata" jsonb,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE IF NOT EXISTS "setup_run_steps" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"setup_run_id" text NOT NULL,
|
|
"step_key" text NOT NULL,
|
|
"status" text DEFAULT 'not_started' NOT NULL,
|
|
"input_hash" text,
|
|
"output_json" jsonb,
|
|
"errors_json" jsonb,
|
|
"warnings_json" jsonb,
|
|
"started_at" timestamp with time zone,
|
|
"completed_at" timestamp with time zone,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX IF NOT EXISTS "setup_run_steps_run_step_idx" ON "setup_run_steps" ("setup_run_id","step_key");
|
|
--> statement-breakpoint
|
|
CREATE TABLE IF NOT EXISTS "seed_manifests" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"setup_run_id" text,
|
|
"organization_id" text,
|
|
"name" text NOT NULL,
|
|
"version" text NOT NULL,
|
|
"type" text NOT NULL,
|
|
"checksum" text NOT NULL,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"source" text NOT NULL,
|
|
"applied_by" text,
|
|
"applied_at" timestamp with time zone,
|
|
"report_json" jsonb,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE TABLE IF NOT EXISTS "seed_manifest_items" (
|
|
"id" text PRIMARY KEY NOT NULL,
|
|
"seed_manifest_id" text NOT NULL,
|
|
"item_key" text NOT NULL,
|
|
"source_file" text NOT NULL,
|
|
"checksum" text NOT NULL,
|
|
"status" text DEFAULT 'pending' NOT NULL,
|
|
"imported_count" integer DEFAULT 0 NOT NULL,
|
|
"updated_count" integer DEFAULT 0 NOT NULL,
|
|
"skipped_count" integer DEFAULT 0 NOT NULL,
|
|
"error_count" integer DEFAULT 0 NOT NULL,
|
|
"warning_count" integer DEFAULT 0 NOT NULL,
|
|
"report_json" jsonb,
|
|
"created_at" timestamp with time zone DEFAULT now() NOT NULL,
|
|
"updated_at" timestamp with time zone DEFAULT now() NOT NULL
|
|
);
|
|
--> statement-breakpoint
|
|
CREATE UNIQUE INDEX IF NOT EXISTS "seed_manifest_items_manifest_item_idx" ON "seed_manifest_items" ("seed_manifest_id","item_key");
|