CREATE TABLE "category_translations" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"category_id" uuid NOT NULL,
	"locale" text NOT NULL,
	"name" text NOT NULL,
	"name_source_hash" text NOT NULL,
	"name_manual_override" boolean DEFAULT false NOT NULL,
	"model_id" text,
	"status" text DEFAULT 'OK' NOT NULL,
	"translated_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 TABLE "tag_translations" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"tag_id" uuid NOT NULL,
	"locale" text NOT NULL,
	"name" text NOT NULL,
	"name_source_hash" text NOT NULL,
	"name_manual_override" boolean DEFAULT false NOT NULL,
	"model_id" text,
	"status" text DEFAULT 'OK' NOT NULL,
	"translated_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 TABLE "vendor_translations" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"vendor_id" uuid NOT NULL,
	"locale" text NOT NULL,
	"display_name" text,
	"display_name_source_hash" text,
	"display_name_manual_override" boolean DEFAULT false NOT NULL,
	"description" text,
	"description_source_hash" text,
	"description_manual_override" boolean DEFAULT false NOT NULL,
	"model_id" text,
	"status" text DEFAULT 'OK' NOT NULL,
	"translated_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
ALTER TABLE "category_translations" ADD CONSTRAINT "category_translations_category_id_deal_categories_id_fk" FOREIGN KEY ("category_id") REFERENCES "public"."deal_categories"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "category_translations" ADD CONSTRAINT "category_translations_locale_languages_code_fk" FOREIGN KEY ("locale") REFERENCES "public"."languages"("code") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "tag_translations" ADD CONSTRAINT "tag_translations_tag_id_deal_tags_id_fk" FOREIGN KEY ("tag_id") REFERENCES "public"."deal_tags"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "tag_translations" ADD CONSTRAINT "tag_translations_locale_languages_code_fk" FOREIGN KEY ("locale") REFERENCES "public"."languages"("code") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "vendor_translations" ADD CONSTRAINT "vendor_translations_vendor_id_vendors_id_fk" FOREIGN KEY ("vendor_id") REFERENCES "public"."vendors"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "vendor_translations" ADD CONSTRAINT "vendor_translations_locale_languages_code_fk" FOREIGN KEY ("locale") REFERENCES "public"."languages"("code") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
CREATE UNIQUE INDEX "category_translations_cat_locale_idx" ON "category_translations" USING btree ("category_id","locale");--> statement-breakpoint
CREATE INDEX "category_translations_locale_status_idx" ON "category_translations" USING btree ("locale","status");--> statement-breakpoint
CREATE UNIQUE INDEX "tag_translations_tag_locale_idx" ON "tag_translations" USING btree ("tag_id","locale");--> statement-breakpoint
CREATE INDEX "tag_translations_locale_status_idx" ON "tag_translations" USING btree ("locale","status");--> statement-breakpoint
CREATE UNIQUE INDEX "vendor_translations_vendor_locale_idx" ON "vendor_translations" USING btree ("vendor_id","locale");--> statement-breakpoint
CREATE INDEX "vendor_translations_locale_status_idx" ON "vendor_translations" USING btree ("locale","status");