CREATE TABLE
	"joblines" (
		"id" uuid PRIMARY KEY DEFAULT gen_random_uuid () NOT NULL,
		"created_at" timestamp
		with
			time zone DEFAULT now () NOT NULL,
			"jobId" uuid NOT NULL,
			"line_desc" text
	);

--> statement-breakpoint
CREATE TABLE
	"jobs" (
		"id" uuid PRIMARY KEY DEFAULT gen_random_uuid () NOT NULL,
		"shopId" uuid NOT NULL,
		"created_at" timestamp
		with
			time zone DEFAULT now () NOT NULL,
			"clm_no" text,
			"ciecaid" text
	);

--> statement-breakpoint
CREATE TABLE
	"shops" (
		"id" uuid PRIMARY KEY DEFAULT gen_random_uuid () NOT NULL,
		"created_at" timestamp
		with
			time zone DEFAULT now () NOT NULL,
			"es_api_key" text NOT NULL,
			"active" boolean DEFAULT true NOT NULL,
			CONSTRAINT "shops_es_api_key_unique" UNIQUE ("es_api_key")
	);

--> statement-breakpoint
ALTER TABLE "joblines" ADD CONSTRAINT "joblines_jobId_jobs_id_fk" FOREIGN KEY ("jobId") REFERENCES "public"."jobs" ("id") ON DELETE no action ON UPDATE no action;

--> statement-breakpoint
ALTER TABLE "jobs" ADD CONSTRAINT "jobs_shopId_shops_id_fk" FOREIGN KEY ("shopId") REFERENCES "public"."shops" ("id") ON DELETE no action ON UPDATE no action;

--> statement-breakpoint
CREATE INDEX "clm_no_idx" ON "jobs" USING btree ("clm_no");