From a17234ab6b64d47b87cd9fc4abb49080548936df Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Fri, 12 Apr 2024 01:27:13 +0000 Subject: [PATCH] Add unique constraints to featuredAdventures and worldTravelCountryRegions tables, and insert data for Canada, Germany, and the US regions. --- migrations/0010_closed_nicolaos.sql | 1 + migrations/0011_legal_red_hulk.sql | 1 + migrations/meta/0010_snapshot.json | 311 +++++++++++++++++++++++++++ migrations/meta/0011_snapshot.json | 319 ++++++++++++++++++++++++++++ migrations/meta/_journal.json | 14 ++ sql/ca.sql | 17 ++ sql/countries.sql | 3 +- sql/de.sql | 20 ++ sql/parks.sql | 97 ++------- sql/us.sql | 54 +++++ src/lib/db/schema.ts | 4 +- 11 files changed, 756 insertions(+), 85 deletions(-) create mode 100644 migrations/0010_closed_nicolaos.sql create mode 100644 migrations/0011_legal_red_hulk.sql create mode 100644 migrations/meta/0010_snapshot.json create mode 100644 migrations/meta/0011_snapshot.json create mode 100644 sql/ca.sql create mode 100644 sql/de.sql create mode 100644 sql/us.sql diff --git a/migrations/0010_closed_nicolaos.sql b/migrations/0010_closed_nicolaos.sql new file mode 100644 index 0000000..3f0f4f0 --- /dev/null +++ b/migrations/0010_closed_nicolaos.sql @@ -0,0 +1 @@ +ALTER TABLE "featuredAdventures" ADD CONSTRAINT "featuredAdventures_name_unique" UNIQUE("name"); \ No newline at end of file diff --git a/migrations/0011_legal_red_hulk.sql b/migrations/0011_legal_red_hulk.sql new file mode 100644 index 0000000..7f6cdfa --- /dev/null +++ b/migrations/0011_legal_red_hulk.sql @@ -0,0 +1 @@ +ALTER TABLE "worldTravelCountryRegions" ADD CONSTRAINT "worldTravelCountryRegions_name_unique" UNIQUE("name"); \ No newline at end of file diff --git a/migrations/meta/0010_snapshot.json b/migrations/meta/0010_snapshot.json new file mode 100644 index 0000000..8824345 --- /dev/null +++ b/migrations/meta/0010_snapshot.json @@ -0,0 +1,311 @@ +{ + "id": "988ebc41-0384-43ed-a4dc-acaf5f14f88b", + "prevId": "309515d8-823e-493d-96c2-aef7ff79a953", + "version": "5", + "dialect": "pg", + "tables": { + "featuredAdventures": { + "name": "featuredAdventures", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "featuredAdventures_name_unique": { + "name": "featuredAdventures_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + } + } + }, + "session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "sharedAdventures": { + "name": "sharedAdventures", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "data": { + "name": "data", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "hashed_password": { + "name": "hashed_password", + "type": "varchar", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "userVisitedAdventures": { + "name": "userVisitedAdventures", + "schema": "", + "columns": { + "adventure_id": { + "name": "adventure_id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "adventure_name": { + "name": "adventure_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "visited_date": { + "name": "visited_date", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "userVisitedAdventures_user_id_user_id_fk": { + "name": "userVisitedAdventures_user_id_user_id_fk", + "tableFrom": "userVisitedAdventures", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "worldTravelCountries": { + "name": "worldTravelCountries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "country_code": { + "name": "country_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "continent": { + "name": "continent", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "worldTravelCountries_country_code_unique": { + "name": "worldTravelCountries_country_code_unique", + "nullsNotDistinct": false, + "columns": [ + "country_code" + ] + } + } + }, + "worldTravelCountryRegions": { + "name": "worldTravelCountryRegions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "country_code": { + "name": "country_code", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "worldTravelCountryRegions_country_code_worldTravelCountries_country_code_fk": { + "name": "worldTravelCountryRegions_country_code_worldTravelCountries_country_code_fk", + "tableFrom": "worldTravelCountryRegions", + "tableTo": "worldTravelCountries", + "columnsFrom": [ + "country_code" + ], + "columnsTo": [ + "country_code" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": {}, + "schemas": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/migrations/meta/0011_snapshot.json b/migrations/meta/0011_snapshot.json new file mode 100644 index 0000000..762a976 --- /dev/null +++ b/migrations/meta/0011_snapshot.json @@ -0,0 +1,319 @@ +{ + "id": "341b817a-4a1f-43ea-9e49-34769fca6da8", + "prevId": "988ebc41-0384-43ed-a4dc-acaf5f14f88b", + "version": "5", + "dialect": "pg", + "tables": { + "featuredAdventures": { + "name": "featuredAdventures", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "featuredAdventures_name_unique": { + "name": "featuredAdventures_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + } + } + }, + "session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "sharedAdventures": { + "name": "sharedAdventures", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "data": { + "name": "data", + "type": "json", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "date": { + "name": "date", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "first_name": { + "name": "first_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "last_name": { + "name": "last_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "icon": { + "name": "icon", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "hashed_password": { + "name": "hashed_password", + "type": "varchar", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "userVisitedAdventures": { + "name": "userVisitedAdventures", + "schema": "", + "columns": { + "adventure_id": { + "name": "adventure_id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "adventure_name": { + "name": "adventure_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "visited_date": { + "name": "visited_date", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "userVisitedAdventures_user_id_user_id_fk": { + "name": "userVisitedAdventures_user_id_user_id_fk", + "tableFrom": "userVisitedAdventures", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "worldTravelCountries": { + "name": "worldTravelCountries", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "country_code": { + "name": "country_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "continent": { + "name": "continent", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "worldTravelCountries_country_code_unique": { + "name": "worldTravelCountries_country_code_unique", + "nullsNotDistinct": false, + "columns": [ + "country_code" + ] + } + } + }, + "worldTravelCountryRegions": { + "name": "worldTravelCountryRegions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "country_code": { + "name": "country_code", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "worldTravelCountryRegions_country_code_worldTravelCountries_country_code_fk": { + "name": "worldTravelCountryRegions_country_code_worldTravelCountries_country_code_fk", + "tableFrom": "worldTravelCountryRegions", + "tableTo": "worldTravelCountries", + "columnsFrom": [ + "country_code" + ], + "columnsTo": [ + "country_code" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "worldTravelCountryRegions_name_unique": { + "name": "worldTravelCountryRegions_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + } + } + } + }, + "enums": {}, + "schemas": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/migrations/meta/_journal.json b/migrations/meta/_journal.json index fbc2529..ef36d66 100644 --- a/migrations/meta/_journal.json +++ b/migrations/meta/_journal.json @@ -71,6 +71,20 @@ "when": 1712880141763, "tag": "0009_zippy_domino", "breakpoints": true + }, + { + "idx": 10, + "version": "5", + "when": 1712884724835, + "tag": "0010_closed_nicolaos", + "breakpoints": true + }, + { + "idx": 11, + "version": "5", + "when": 1712885083355, + "tag": "0011_legal_red_hulk", + "breakpoints": true } ] } \ No newline at end of file diff --git a/sql/ca.sql b/sql/ca.sql new file mode 100644 index 0000000..d814a98 --- /dev/null +++ b/sql/ca.sql @@ -0,0 +1,17 @@ +INSERT INTO "worldTravelCountryRegions" (name, country_code) +VALUES + ('Alberta', 'ca'), + ('British Columbia', 'ca'), + ('Manitoba', 'ca'), + ('New Brunswick', 'ca'), + ('Newfoundland and Labrador', 'ca'), + ('Nova Scotia', 'ca'), + ('Ontario', 'ca'), + ('Prince Edward Island', 'ca'), + ('Quebec', 'ca'), + ('Saskatchewan', 'ca'), + ('Northwest Territories', 'ca'), + ('Nunavut', 'ca'), + ('Yukon', 'ca'); + +ON CONFLICT (name) DO NOTHING; diff --git a/sql/countries.sql b/sql/countries.sql index adfc955..9789561 100644 --- a/sql/countries.sql +++ b/sql/countries.sql @@ -14,4 +14,5 @@ VALUES ('Australia', 'au', 'Oceania'), ('New Zealand', 'nz', 'Oceania'), ('South Africa', 'za', 'Africa'), - ('Egypt', 'eg', 'Africa'); + ('Egypt', 'eg', 'Africa'), +ON CONFLICT (country_code) DO NOTHING; \ No newline at end of file diff --git a/sql/de.sql b/sql/de.sql new file mode 100644 index 0000000..f694365 --- /dev/null +++ b/sql/de.sql @@ -0,0 +1,20 @@ +INSERT INTO "worldTravelCountryRegions" (name, country_code) +VALUES + ('Baden-Württemberg', 'de'), + ('Bavaria', 'de'), + ('Berlin', 'de'), + ('Brandenburg', 'de'), + ('Bremen', 'de'), + ('Hamburg', 'de'), + ('Hesse', 'de'), + ('Lower Saxony', 'de'), + ('Mecklenburg-Vorpommern', 'de'), + ('North Rhine-Westphalia', 'de'), + ('Rhineland-Palatinate', 'de'), + ('Saarland', 'de'), + ('Saxony', 'de'), + ('Saxony-Anhalt', 'de'), + ('Schleswig-Holstein', 'de'), + ('Thuringia', 'de'); + +ON CONFLICT (name) DO NOTHING; diff --git a/sql/parks.sql b/sql/parks.sql index 701017d..b8697f4 100644 --- a/sql/parks.sql +++ b/sql/parks.sql @@ -1,82 +1,15 @@ -INSERT INTO "featuredAdventures" (id, name, location) VALUES - (20, 'Yellowstone National Park', 'Wyoming, Montana, Idaho, USA'), - (21, 'Yosemite National Park', 'California, USA'), - (22, 'Banff National Park', 'Alberta, Canada'), - (23, 'Kruger National Park', 'Limpopo, South Africa'), - (24, 'Grand Canyon National Park', 'Arizona, USA'), - (25, 'Great Smoky Mountains National Park', 'North Carolina, Tennessee, USA'), - (26, 'Zion National Park', 'Utah, USA'), - (27, 'Glacier National Park', 'Montana, USA'), - (28, 'Rocky Mountain National Park', 'Colorado, USA'), - (29, 'Everglades National Park', 'Florida, USA'), - (30, 'Arches National Park', 'Utah, USA'), - (31, 'Acadia National Park', 'Maine, USA'), - (32, 'Sequoia National Park', 'California, USA'), - (33, 'Joshua Tree National Park', 'California, USA'), - (34, 'Yellowstone National Park', 'Wyoming, Montana, Idaho, USA'), - (35, 'Bryce Canyon National Park', 'Utah, USA'), - (36, 'Grand Teton National Park', 'Wyoming, USA'), - (37, 'Denali National Park', 'Alaska, USA'), - (38, 'Olympic National Park', 'Washington, USA'), - (39, 'Canyonlands National Park', 'Utah, USA'), - (40, 'Death Valley National Park', 'California, Nevada, USA'), - (41, 'Redwood National and State Parks', 'California, USA'), - (42, 'Waterton Lakes National Park', 'Alberta, Canada'), - (43, 'Mesa Verde National Park', 'Colorado, USA'), - (44, 'Petrified Forest National Park', 'Arizona, USA'), - (45, 'Capitol Reef National Park', 'Utah, USA'), - (46, 'Yellowstone National Park', 'Wyoming, Montana, Idaho, USA'), - (47, 'Yosemite National Park', 'California, USA'), - (48, 'Banff National Park', 'Alberta, Canada'), - (49, 'Kruger National Park', 'Limpopo, South Africa'), - (50, 'Grand Canyon National Park', 'Arizona, USA'), - (51, 'Great Smoky Mountains National Park', 'North Carolina, Tennessee, USA'), - (52, 'Zion National Park', 'Utah, USA'), - (53, 'Glacier National Park', 'Montana, USA'), - (54, 'Rocky Mountain National Park', 'Colorado, USA'), - (55, 'Everglades National Park', 'Florida, USA'), - (56, 'Arches National Park', 'Utah, USA'), - (57, 'Acadia National Park', 'Maine, USA'), - (58, 'Sequoia National Park', 'California, USA'), - (59, 'Joshua Tree National Park', 'California, USA'), - (60, 'Yellowstone National Park', 'Wyoming, Montana, Idaho, USA'), - (61, 'Bryce Canyon National Park', 'Utah, USA'), - (62, 'Grand Teton National Park', 'Wyoming, USA'), - (63, 'Denali National Park', 'Alaska, USA'), - (64, 'Olympic National Park', 'Washington, USA'), - (65, 'Canyonlands National Park', 'Utah, USA'), - (66, 'Yellowstone National Park', 'Wyoming, Montana, Idaho, USA'), - (67, 'Yosemite National Park', 'California, USA'), - (68, 'Banff National Park', 'Alberta, Canada'), - (69, 'Kruger National Park', 'Limpopo, South Africa'), - (70, 'Grand Canyon National Park', 'Arizona, USA'), - (71, 'Great Smoky Mountains National Park', 'North Carolina, Tennessee, USA'), - (72, 'Zion National Park', 'Utah, USA'), - (73, 'Glacier National Park', 'Montana, USA'), - (74, 'Rocky Mountain National Park', 'Colorado, USA'), - (75, 'Everglades National Park', 'Florida, USA'), - (76, 'Arches National Park', 'Utah, USA'), - (77, 'Acadia National Park', 'Maine, USA'), - (78, 'Sequoia National Park', 'California, USA'), - (79, 'Joshua Tree National Park', 'California, USA'), - (80, 'Yellowstone National Park', 'Wyoming, Montana, Idaho, USA'), - (81, 'Bryce Canyon National Park', 'Utah, USA'), - (82, 'Grand Teton National Park', 'Wyoming, USA'), - (83, 'Denali National Park', 'Alaska, USA'), - (84, 'Olympic National Park', 'Washington, USA'), - (85, 'Canyonlands National Park', 'Utah, USA'), - (86, 'Yellowstone National Park', 'Wyoming, Montana, Idaho, USA'), - (87, 'Yosemite National Park', 'California, USA'), - (88, 'Banff National Park', 'Alberta, Canada'), - (89, 'Kruger National Park', 'Limpopo, South Africa'), - (90, 'Grand Canyon National Park', 'Arizona, USA'), - (91, 'Great Smoky Mountains National Park', 'North Carolina, Tennessee, USA'), - (92, 'Zion National Park', 'Utah, USA'), - (93, 'Glacier National Park', 'Montana, USA'), - (94, 'Rocky Mountain National Park', 'Colorado, USA'), - (95, 'Everglades National Park', 'Florida, USA'), - (96, 'Arches National Park', 'Utah, USA'), - (97, 'Acadia National Park', 'Maine, USA'), - (98, 'Sequoia National Park', 'California, USA'), - (99, 'Joshua Tree National Park', 'California, USA'); -ON CONFLICT (id) DO NOTHING; \ No newline at end of file +INSERT INTO "featuredAdventures" (name, location) VALUES + ('Yellowstone National Park', 'Wyoming, Montana, Idaho, USA'), + ('Yosemite National Park', 'California, USA'), + ('Banff National Park', 'Alberta, Canada'), + ('Kruger National Park', 'Limpopo, South Africa'), + ('Grand Canyon National Park', 'Arizona, USA'), + ('Great Smoky Mountains National Park', 'North Carolina, Tennessee, USA'), + ('Zion National Park', 'Utah, USA'), + ('Glacier National Park', 'Montana, USA'), + ('Rocky Mountain National Park', 'Colorado, USA'), + ('Everglades National Park', 'Florida, USA'), + ('Arches National Park', 'Utah, USA'), + ('Acadia National Park', 'Maine, USA'), + ('Sequoia National Park', 'California, USA') +ON CONFLICT (name) DO NOTHING; \ No newline at end of file diff --git a/sql/us.sql b/sql/us.sql new file mode 100644 index 0000000..5ddd9cd --- /dev/null +++ b/sql/us.sql @@ -0,0 +1,54 @@ +INSERT INTO "worldTravelCountryRegions" (name, country_code) +VALUES + ('Alabama', 'us'), + ('Alaska', 'us'), + ('Arizona', 'us'), + ('Arkansas', 'us'), + ('California', 'us'), + ('Colorado', 'us'), + ('Connecticut', 'us'), + ('Delaware', 'us'), + ('Florida', 'us'), + ('Georgia', 'us'), + ('Hawaii', 'us'), + ('Idaho', 'us'), + ('Illinois', 'us'), + ('Indiana', 'us'), + ('Iowa', 'us'), + ('Kansas', 'us'), + ('Kentucky', 'us'), + ('Louisiana', 'us'), + ('Maine', 'us'), + ('Maryland', 'us'), + ('Massachusetts', 'us'), + ('Michigan', 'us'), + ('Minnesota', 'us'), + ('Mississippi', 'us'), + ('Missouri', 'us'), + ('Montana', 'us'), + ('Nebraska', 'us'), + ('Nevada', 'us'), + ('New Hampshire', 'us'), + ('New Jersey', 'us'), + ('New Mexico', 'us'), + ('New York', 'us'), + ('North Carolina', 'us'), + ('North Dakota', 'us'), + ('Ohio', 'us'), + ('Oklahoma', 'us'), + ('Oregon', 'us'), + ('Pennsylvania', 'us'), + ('Rhode Island', 'us'), + ('South Carolina', 'us'), + ('South Dakota', 'us'), + ('Tennessee', 'us'), + ('Texas', 'us'), + ('Utah', 'us'), + ('Vermont', 'us'), + ('Virginia', 'us'), + ('Washington', 'us'), + ('West Virginia', 'us'), + ('Wisconsin', 'us'), + ('Wyoming', 'us'); + +ON CONFLICT (name) DO NOTHING; diff --git a/src/lib/db/schema.ts b/src/lib/db/schema.ts index 0a247b2..3ecc8bc 100644 --- a/src/lib/db/schema.ts +++ b/src/lib/db/schema.ts @@ -11,7 +11,7 @@ import { export const featuredAdventures = pgTable("featuredAdventures", { id: serial("id").primaryKey(), - name: text("name").notNull(), + name: text("name").notNull().unique(), location: text("location"), }); @@ -63,7 +63,7 @@ export const worldTravelCountries = pgTable("worldTravelCountries", { export const worldTravelCountryRegions = pgTable("worldTravelCountryRegions", { id: serial("id").primaryKey(), - name: text("name").notNull(), + name: text("name").notNull().unique(), country_code: text("country_code") .notNull() .references(() => worldTravelCountries.country_code),