CREATE TABLE "languages" (
	"code" text PRIMARY KEY NOT NULL,
	"name_native" text NOT NULL,
	"name_english" text NOT NULL,
	"direction" text NOT NULL,
	"search_config" text NOT NULL,
	"is_active" boolean DEFAULT true NOT NULL,
	"is_default" boolean DEFAULT false NOT NULL,
	"sort_order" integer DEFAULT 0 NOT NULL,
	"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 "languages_one_default_idx" ON "languages" USING btree ("is_default") WHERE "languages"."is_default" = true;--> statement-breakpoint
CREATE INDEX "languages_active_sort_idx" ON "languages" USING btree ("is_active","sort_order");

INSERT INTO "languages" ("code","name_native","name_english","direction","search_config","is_active","is_default","sort_order")
VALUES
  ('he','עברית','Hebrew','rtl','simple',true,true,0),
  ('en','English','English','ltr','english',true,false,1)
ON CONFLICT ("code") DO NOTHING;