Add unique constraint to worldTravelCountries.country_code and create worldTravelCountryRegions table

This commit is contained in:
Sean Morley
2024-04-12 00:03:14 +00:00
parent a03fc5fb4e
commit d190222573
6 changed files with 599 additions and 1 deletions

View File

@@ -0,0 +1,11 @@
CREATE TABLE IF NOT EXISTS "worldTravelCountryRegions" (
"id" serial PRIMARY KEY NOT NULL,
"name" text NOT NULL,
"country_code" text NOT NULL
);
--> statement-breakpoint
DO $$ BEGIN
ALTER TABLE "worldTravelCountryRegions" ADD CONSTRAINT "worldTravelCountryRegions_country_code_worldTravelCountries_country_code_fk" FOREIGN KEY ("country_code") REFERENCES "worldTravelCountries"("country_code") ON DELETE no action ON UPDATE no action;
EXCEPTION
WHEN duplicate_object THEN null;
END $$;