Shumiland/migrations/0005_site_settings_tariff_labels.sql
Vadym Samoilenko f3c3d2c978
Some checks failed
CI / Type Check (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Unit Tests (push) Has been cancelled
Deploy / Build & Push Image (push) Has been cancelled
Deploy / Deploy to VPS (push) Has been cancelled
feat(migration): 0005 — add site_settings_tariff_category_labels table
Sub-table for the tariffCategoryLabels array field added to SiteSettings
global. Was missing from prod DB causing query failures on every page load.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-18 13:36:54 +01:00

21 lines
964 B
SQL

-- Migration 0005: site_settings_tariff_category_labels sub-table
-- Added when tariffCategoryLabels array field was added to SiteSettings global
CREATE TABLE IF NOT EXISTS "site_settings_tariff_category_labels" (
"_order" integer NOT NULL,
"_parent_id" integer NOT NULL,
"id" varchar PRIMARY KEY NOT NULL,
"key" varchar NOT NULL,
"label" varchar NOT NULL
);
DO $$ BEGIN
ALTER TABLE "site_settings_tariff_category_labels" ADD CONSTRAINT "site_settings_tariff_category_labels_parent_id_fk"
FOREIGN KEY ("_parent_id") REFERENCES "public"."site_settings"("id") ON DELETE cascade ON UPDATE no action;
EXCEPTION WHEN duplicate_object THEN null; END $$;
CREATE INDEX IF NOT EXISTS "site_settings_tariff_category_labels_order_idx"
ON "site_settings_tariff_category_labels" USING btree ("_order");
CREATE INDEX IF NOT EXISTS "site_settings_tariff_category_labels_parent_id_idx"
ON "site_settings_tariff_category_labels" USING btree ("_parent_id");