From 61458b3cc231f1f4a012440a72c947bb0b571635 Mon Sep 17 00:00:00 2001 From: Sean Morley Date: Fri, 12 Apr 2024 14:04:23 +0000 Subject: [PATCH] Add country regions for Germany, South Africa, Australia, New Zealand, Egypt, Brazil, China --- migrations/0016_curvy_purple_man.sql | 1 + migrations/meta/0016_snapshot.json | 319 +++++++++++++++++++++++++++ migrations/meta/_journal.json | 7 + sql/004_de.sql | 2 +- sql/010_cn.sql | 35 +++ sql/011_in.sql | 39 ++++ sql/012_au.sql | 12 + sql/013_nz.sql | 20 ++ sql/014_za.sql | 13 ++ sql/015_eg.sql | 31 +++ sql/016_br.sql | 31 +++ src/lib/db/schema.ts | 2 +- 12 files changed, 510 insertions(+), 2 deletions(-) create mode 100644 migrations/0016_curvy_purple_man.sql create mode 100644 migrations/meta/0016_snapshot.json create mode 100644 sql/010_cn.sql create mode 100644 sql/011_in.sql create mode 100644 sql/012_au.sql create mode 100644 sql/013_nz.sql create mode 100644 sql/014_za.sql create mode 100644 sql/015_eg.sql create mode 100644 sql/016_br.sql diff --git a/migrations/0016_curvy_purple_man.sql b/migrations/0016_curvy_purple_man.sql new file mode 100644 index 0000000..b8c4b7e --- /dev/null +++ b/migrations/0016_curvy_purple_man.sql @@ -0,0 +1 @@ +ALTER TABLE "worldTravelCountryRegions" DROP CONSTRAINT "worldTravelCountryRegions_name_unique"; \ No newline at end of file diff --git a/migrations/meta/0016_snapshot.json b/migrations/meta/0016_snapshot.json new file mode 100644 index 0000000..2e6b21b --- /dev/null +++ b/migrations/meta/0016_snapshot.json @@ -0,0 +1,319 @@ +{ + "id": "4ec66da5-6bf4-41ac-b998-95f1e14a5372", + "prevId": "08e82a7f-26df-4a30-a7d0-8e6043a2de43", + "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": "varchar", + "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_id_unique": { + "name": "worldTravelCountryRegions_id_unique", + "nullsNotDistinct": false, + "columns": [ + "id" + ] + } + } + } + }, + "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 b703e7c..268be84 100644 --- a/migrations/meta/_journal.json +++ b/migrations/meta/_journal.json @@ -113,6 +113,13 @@ "when": 1712928491810, "tag": "0015_nappy_spot", "breakpoints": true + }, + { + "idx": 16, + "version": "5", + "when": 1712930531576, + "tag": "0016_curvy_purple_man", + "breakpoints": true } ] } \ No newline at end of file diff --git a/sql/004_de.sql b/sql/004_de.sql index 311f67f..a8be86c 100644 --- a/sql/004_de.sql +++ b/sql/004_de.sql @@ -15,6 +15,6 @@ VALUES ('DE-SN', 'Saxony', 'de'), ('DE-ST', 'Saxony-Anhalt', 'de'), ('DE-SH', 'Schleswig-Holstein', 'de'), - ('DE-TH', 'Thuringia', 'de'); + ('DE-TH', 'Thuringia', 'de') ON CONFLICT (id) DO NOTHING; diff --git a/sql/010_cn.sql b/sql/010_cn.sql new file mode 100644 index 0000000..c7353ae --- /dev/null +++ b/sql/010_cn.sql @@ -0,0 +1,35 @@ +INSERT INTO "worldTravelCountryRegions" (id, name, country_code) +VALUES + ('CN-BJ', 'Beijing', 'cn'), + ('CN-TJ', 'Tianjin', 'cn'), + ('CN-HE', 'Hebei', 'cn'), + ('CN-SX', 'Shanxi', 'cn'), + ('CN-NM', 'Inner Mongolia', 'cn'), + ('CN-LN', 'Liaoning', 'cn'), + ('CN-JL', 'Jilin', 'cn'), + ('CN-HL', 'Heilongjiang', 'cn'), + ('CN-SH', 'Shanghai', 'cn'), + ('CN-JS', 'Jiangsu', 'cn'), + ('CN-ZJ', 'Zhejiang', 'cn'), + ('CN-AH', 'Anhui', 'cn'), + ('CN-FJ', 'Fujian', 'cn'), + ('CN-JX', 'Jiangxi', 'cn'), + ('CN-SD', 'Shandong', 'cn'), + ('CN-HA', 'Henan', 'cn'), + ('CN-HB', 'Hubei', 'cn'), + ('CN-HN', 'Hunan', 'cn'), + ('CN-GD', 'Guangdong', 'cn'), + ('CN-GX', 'Guangxi', 'cn'), + ('CN-HI', 'Hainan', 'cn'), + ('CN-CQ', 'Chongqing', 'cn'), + ('CN-SC', 'Sichuan', 'cn'), + ('CN-GZ', 'Guizhou', 'cn'), + ('CN-YN', 'Yunnan', 'cn'), + ('CN-XZ', 'Tibet', 'cn'), + ('CN-SA', 'Shaanxi', 'cn'), + ('CN-GS', 'Gansu', 'cn'), + ('CN-QH', 'Qinghai', 'cn'), + ('CN-NX', 'Ningxia', 'cn'), + ('CN-XJ', 'Xinjiang', 'cn') + +ON CONFLICT (id) DO NOTHING; diff --git a/sql/011_in.sql b/sql/011_in.sql new file mode 100644 index 0000000..45c76b6 --- /dev/null +++ b/sql/011_in.sql @@ -0,0 +1,39 @@ +INSERT INTO "worldTravelCountryRegions" (id, name, country_code) +VALUES + ('IN-AN', 'Andaman and Nicobar Islands', 'in'), + ('IN-AP', 'Andhra Pradesh', 'in'), + ('IN-AR', 'Arunachal Pradesh', 'in'), + ('IN-AS', 'Assam', 'in'), + ('IN-BR', 'Bihar', 'in'), + ('IN-CH', 'Chandigarh', 'in'), + ('IN-CT', 'Chhattisgarh', 'in'), + ('IN-DN', 'Dadra and Nagar Haveli and Daman and Diu', 'in'), + ('IN-DD', 'Daman and Diu', 'in'), -- These IDs are consolidated now, but adding separately for compatibility + ('IN-DL', 'Delhi', 'in'), + ('IN-GA', 'Goa', 'in'), + ('IN-GJ', 'Gujarat', 'in'), + ('IN-HR', 'Haryana', 'in'), + ('IN-HP', 'Himachal Pradesh', 'in'), + ('IN-JH', 'Jharkhand', 'in'), + ('IN-KA', 'Karnataka', 'in'), + ('IN-KL', 'Kerala', 'in'), + ('IN-LD', 'Lakshadweep', 'in'), + ('IN-MP', 'Madhya Pradesh', 'in'), + ('IN-MH', 'Maharashtra', 'in'), + ('IN-MN', 'Manipur', 'in'), + ('IN-ML', 'Meghalaya', 'in'), + ('IN-MZ', 'Mizoram', 'in'), + ('IN-NL', 'Nagaland', 'in'), + ('IN-OR', 'Odisha', 'in'), + ('IN-PY', 'Puducherry', 'in'), + ('IN-PB', 'Punjab', 'in'), + ('IN-RJ', 'Rajasthan', 'in'), + ('IN-SK', 'Sikkim', 'in'), + ('IN-TN', 'Tamil Nadu', 'in'), + ('IN-TG', 'Telangana', 'in'), + ('IN-TR', 'Tripura', 'in'), + ('IN-UP', 'Uttar Pradesh', 'in'), + ('IN-UT', 'Uttarakhand', 'in'), + ('IN-WB', 'West Bengal', 'in') + +ON CONFLICT (id) DO NOTHING; diff --git a/sql/012_au.sql b/sql/012_au.sql new file mode 100644 index 0000000..8882314 --- /dev/null +++ b/sql/012_au.sql @@ -0,0 +1,12 @@ +INSERT INTO "worldTravelCountryRegions" (id, name, country_code) +VALUES + ('AU-NSW', 'New South Wales', 'au'), + ('AU-VIC', 'Victoria', 'au'), + ('AU-QLD', 'Queensland', 'au'), + ('AU-SA', 'South Australia', 'au'), + ('AU-WA', 'Western Australia', 'au'), + ('AU-TAS', 'Tasmania', 'au'), + ('AU-NT', 'Northern Territory', 'au'), + ('AU-ACT', 'Australian Capital Territory', 'au') + +ON CONFLICT (id) DO NOTHING; diff --git a/sql/013_nz.sql b/sql/013_nz.sql new file mode 100644 index 0000000..9d20865 --- /dev/null +++ b/sql/013_nz.sql @@ -0,0 +1,20 @@ +INSERT INTO "worldTravelCountryRegions" (id, name, country_code) +VALUES + ('NZ-N', 'Northland', 'nz'), + ('NZ-AUK', 'Auckland', 'nz'), + ('NZ-WKO', 'Waikato', 'nz'), + ('NZ-BOP', 'Bay of Plenty', 'nz'), + ('NZ-GIS', 'Gisborne', 'nz'), + ('NZ-HKB', 'Hawke''s Bay', 'nz'), + ('NZ-TKI', 'Taranaki', 'nz'), + ('NZ-MWT', 'Manawatū-Whanganui', 'nz'), + ('NZ-WGN', 'Wellington', 'nz'), + ('NZ-TAS', 'Tasman', 'nz'), + ('NZ-NEL', 'Nelson', 'nz'), + ('NZ-MBH', 'Marlborough', 'nz'), + ('NZ-WTC', 'West Coast', 'nz'), + ('NZ-CAN', 'Canterbury', 'nz'), + ('NZ-OTA', 'Otago', 'nz'), + ('NZ-STL', 'Southland', 'nz') + +ON CONFLICT (id) DO NOTHING; diff --git a/sql/014_za.sql b/sql/014_za.sql new file mode 100644 index 0000000..44b493c --- /dev/null +++ b/sql/014_za.sql @@ -0,0 +1,13 @@ +INSERT INTO "worldTravelCountryRegions" (id, name, country_code) +VALUES + ('ZA-EC', 'Eastern Cape', 'za'), + ('ZA-FS', 'Free State', 'za'), + ('ZA-GP', 'Gauteng', 'za'), + ('ZA-KZN', 'KwaZulu-Natal', 'za'), + ('ZA-LP', 'Limpopo', 'za'), + ('ZA-MP', 'Mpumalanga', 'za'), + ('ZA-NW', 'North West', 'za'), + ('ZA-NC', 'Northern Cape', 'za'), + ('ZA-WC', 'Western Cape', 'za') + +ON CONFLICT (id) DO NOTHING; diff --git a/sql/015_eg.sql b/sql/015_eg.sql new file mode 100644 index 0000000..21c5e66 --- /dev/null +++ b/sql/015_eg.sql @@ -0,0 +1,31 @@ +INSERT INTO "worldTravelCountryRegions" (id, name, country_code) +VALUES + ('EG-ALX', 'Alexandria', 'eg'), + ('EG-ASN', 'Aswan', 'eg'), + ('EG-ASY', 'Asyut', 'eg'), + ('EG-BHR', 'Beheira', 'eg'), + ('EG-BNS', 'Beni Suef', 'eg'), + ('EG-C', 'Cairo', 'eg'), + ('EG-DK', 'Dakahlia', 'eg'), + ('EG-DAM', 'Damietta', 'eg'), + ('EG-FYM', 'Faiyum', 'eg'), + ('EG-GH', 'Gharbia', 'eg'), + ('EG-GZ', 'Giza', 'eg'), + ('EG-IS', 'Ismailia', 'eg'), + ('EG-KB', 'Kafr El Sheikh', 'eg'), + ('EG-LX', 'Luxor', 'eg'), + ('EG-MN', 'Minya', 'eg'), + ('EG-MT', 'Matrouh', 'eg'), + ('EG-QH', 'Qalyubia', 'eg'), + ('EG-KFS', 'Qena', 'eg'), + ('EG-SHG', 'Sohag', 'eg'), + ('EG-SHR', 'Sharqia', 'eg'), + ('EG-SIN', 'South Sinai', 'eg'), + ('EG-SW', 'Suez', 'eg'), + ('EG-WAD', 'New Valley', 'eg'), + ('EG-ASD', 'North Sinai', 'eg'), + ('EG-PTS', 'Port Said', 'eg'), + ('EG-SKB', 'Suez', 'eg'), + ('EG-ESI', 'Ismailia', 'eg') + +ON CONFLICT (id) DO NOTHING; diff --git a/sql/016_br.sql b/sql/016_br.sql new file mode 100644 index 0000000..6bbbd2b --- /dev/null +++ b/sql/016_br.sql @@ -0,0 +1,31 @@ +INSERT INTO "worldTravelCountryRegions" (id, name, country_code) +VALUES + ('BR-AC', 'Acre', 'br'), + ('BR-AL', 'Alagoas', 'br'), + ('BR-AP', 'Amapá', 'br'), + ('BR-AM', 'Amazonas', 'br'), + ('BR-BA', 'Bahia', 'br'), + ('BR-CE', 'Ceará', 'br'), + ('BR-DF', 'Federal District', 'br'), + ('BR-ES', 'Espírito Santo', 'br'), + ('BR-GO', 'Goiás', 'br'), + ('BR-MA', 'Maranhão', 'br'), + ('BR-MT', 'Mato Grosso', 'br'), + ('BR-MS', 'Mato Grosso do Sul', 'br'), + ('BR-MG', 'Minas Gerais', 'br'), + ('BR-PA', 'Pará', 'br'), + ('BR-PB', 'Paraíba', 'br'), + ('BR-PR', 'Paraná', 'br'), + ('BR-PE', 'Pernambuco', 'br'), + ('BR-PI', 'Piauí', 'br'), + ('BR-RJ', 'Rio de Janeiro', 'br'), + ('BR-RN', 'Rio Grande do Norte', 'br'), + ('BR-RS', 'Rio Grande do Sul', 'br'), + ('BR-RO', 'Rondônia', 'br'), + ('BR-RR', 'Roraima', 'br'), + ('BR-SC', 'Santa Catarina', 'br'), + ('BR-SP', 'São Paulo', 'br'), + ('BR-SE', 'Sergipe', 'br'), + ('BR-TO', 'Tocantins', 'br') + +ON CONFLICT (id) DO NOTHING; diff --git a/src/lib/db/schema.ts b/src/lib/db/schema.ts index 2dc3661..f5830ed 100644 --- a/src/lib/db/schema.ts +++ b/src/lib/db/schema.ts @@ -62,7 +62,7 @@ export const worldTravelCountries = pgTable("worldTravelCountries", { export const worldTravelCountryRegions = pgTable("worldTravelCountryRegions", { id: varchar("id").primaryKey().unique(), - name: text("name").notNull().unique(), + name: text("name").notNull(), country_code: text("country_code") .notNull() .references(() => worldTravelCountries.country_code),