CREATE TABLE "ticket_translations" (
	"id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
	"tenant_id" uuid NOT NULL,
	"ticket_id" uuid NOT NULL,
	"language" text NOT NULL,
	"title" text,
	"department" text,
	"issue_category" text,
	"affected_system" text,
	"success_criteria" text,
	"action_requested" text,
	"source_content_hash" text NOT NULL,
	"translation_source" text NOT NULL,
	"review_status" text DEFAULT 'pending' NOT NULL,
	"reviewed_by_id" uuid,
	"reviewed_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,
	CONSTRAINT "ticket_translations_ticket_language_unique" UNIQUE("ticket_id","language")
);
--> statement-breakpoint
ALTER TABLE "ticket_translations" ADD CONSTRAINT "ticket_translations_tenant_id_tenants_id_fk" FOREIGN KEY ("tenant_id") REFERENCES "public"."tenants"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "ticket_translations" ADD CONSTRAINT "ticket_translations_ticket_id_tickets_id_fk" FOREIGN KEY ("ticket_id") REFERENCES "public"."tickets"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "ticket_translations" ADD CONSTRAINT "ticket_translations_reviewed_by_id_users_id_fk" FOREIGN KEY ("reviewed_by_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
CREATE INDEX "ticket_translations_tenant_idx" ON "ticket_translations" USING btree ("tenant_id","ticket_id");