diff --git a/migrations/0001_closed_wendell_vaughn.sql b/migrations/0001_closed_wendell_vaughn.sql new file mode 100644 index 0000000..9f9d831 --- /dev/null +++ b/migrations/0001_closed_wendell_vaughn.sql @@ -0,0 +1,6 @@ +ALTER TABLE "userVisitedWorldTravel" ADD COLUMN "country_code" text NOT NULL;--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "userVisitedWorldTravel" ADD CONSTRAINT "userVisitedWorldTravel_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 $$; diff --git a/migrations/0002_far_mephistopheles.sql b/migrations/0002_far_mephistopheles.sql new file mode 100644 index 0000000..5a0139a --- /dev/null +++ b/migrations/0002_far_mephistopheles.sql @@ -0,0 +1 @@ +ALTER TABLE "worldTravelCountryRegions" ADD COLUMN "info" json; \ No newline at end of file diff --git a/migrations/meta/0001_snapshot.json b/migrations/meta/0001_snapshot.json new file mode 100644 index 0000000..6c4e538 --- /dev/null +++ b/migrations/meta/0001_snapshot.json @@ -0,0 +1,385 @@ +{ + "id": "4c095e1a-9f13-4899-aa83-f56864191f51", + "prevId": "b6ab23b7-42f0-4475-aa5d-23b92c00e97f", + "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": {} + }, + "userVisitedWorldTravel": { + "name": "userVisitedWorldTravel", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "country_code": { + "name": "country_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "region_id": { + "name": "region_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "userVisitedWorldTravel_country_code_worldTravelCountries_country_code_fk": { + "name": "userVisitedWorldTravel_country_code_worldTravelCountries_country_code_fk", + "tableFrom": "userVisitedWorldTravel", + "tableTo": "worldTravelCountries", + "columnsFrom": [ + "country_code" + ], + "columnsTo": [ + "country_code" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "userVisitedWorldTravel_user_id_user_id_fk": { + "name": "userVisitedWorldTravel_user_id_user_id_fk", + "tableFrom": "userVisitedWorldTravel", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "userVisitedWorldTravel_region_id_worldTravelCountryRegions_id_fk": { + "name": "userVisitedWorldTravel_region_id_worldTravelCountryRegions_id_fk", + "tableFrom": "userVisitedWorldTravel", + "tableTo": "worldTravelCountryRegions", + "columnsFrom": [ + "region_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": {} + } + }, + "enums": {}, + "schemas": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/migrations/meta/0002_snapshot.json b/migrations/meta/0002_snapshot.json new file mode 100644 index 0000000..f84336c --- /dev/null +++ b/migrations/meta/0002_snapshot.json @@ -0,0 +1,391 @@ +{ + "id": "91692e84-91ec-4411-ad9d-7b8b14f67dda", + "prevId": "4c095e1a-9f13-4899-aa83-f56864191f51", + "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": {} + }, + "userVisitedWorldTravel": { + "name": "userVisitedWorldTravel", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "country_code": { + "name": "country_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "region_id": { + "name": "region_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "userVisitedWorldTravel_country_code_worldTravelCountries_country_code_fk": { + "name": "userVisitedWorldTravel_country_code_worldTravelCountries_country_code_fk", + "tableFrom": "userVisitedWorldTravel", + "tableTo": "worldTravelCountries", + "columnsFrom": [ + "country_code" + ], + "columnsTo": [ + "country_code" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "userVisitedWorldTravel_user_id_user_id_fk": { + "name": "userVisitedWorldTravel_user_id_user_id_fk", + "tableFrom": "userVisitedWorldTravel", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "userVisitedWorldTravel_region_id_worldTravelCountryRegions_id_fk": { + "name": "userVisitedWorldTravel_region_id_worldTravelCountryRegions_id_fk", + "tableFrom": "userVisitedWorldTravel", + "tableTo": "worldTravelCountryRegions", + "columnsFrom": [ + "region_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 + }, + "info": { + "name": "info", + "type": "json", + "primaryKey": false, + "notNull": false + } + }, + "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/_journal.json b/migrations/meta/_journal.json index ce56d99..12ecd45 100644 --- a/migrations/meta/_journal.json +++ b/migrations/meta/_journal.json @@ -8,6 +8,20 @@ "when": 1713037717607, "tag": "0000_hard_mach_iv", "breakpoints": true + }, + { + "idx": 1, + "version": "5", + "when": 1713050481064, + "tag": "0001_closed_wendell_vaughn", + "breakpoints": true + }, + { + "idx": 2, + "version": "5", + "when": 1713125110816, + "tag": "0002_far_mephistopheles", + "breakpoints": true } ] } \ No newline at end of file diff --git a/sql/002_us.sql b/sql/002_us.sql index aef770c..efa1082 100644 --- a/sql/002_us.sql +++ b/sql/002_us.sql @@ -1,5 +1,222 @@ -INSERT INTO "worldTravelCountryRegions" (id, name, country_code) -VALUES +-- INSERT INTO "worldTravelCountryRegions" (id, name, country_code) +-- VALUES +-- ('US-AL', 'Alabama', 'us', '{ +-- "name": "Alabama", +-- "abbreviation": "AL", +-- "description": "Alabama is a state located in the southeastern region of the United States. Known for its rich history, including its role in the American Civil War and the Civil Rights Movement, Alabama offers a diverse landscape of mountains, plains, and coastal areas. The state boasts a humid subtropical climate and is known for its strong tradition in college sports, particularly football. Alabama''s economy is diverse, with major industries including automotive manufacturing, agriculture, and aerospace. Tourists are drawn to Alabama''s natural beauty, historical sites, and cultural landmarks.", +-- "capital": "Montgomery", +-- "largest_city": "Birmingham", +-- "area": { +-- "total": 52420, +-- "units": "square miles" +-- }, +-- "population": { +-- "estimate": 4903185, +-- "year": 2020 +-- }, +-- "state_flower": "Camellia", +-- "state_bird": "Yellowhammer", +-- "state_tree": "Southern Longleaf Pine", +-- "climate": { +-- "description": "Humid subtropical", +-- "summer_highs": "80-90°F", +-- "winter_lows": "30-50°F", +-- "precipitation": "Abundant throughout the year" +-- }, +-- "economy": { +-- "industries": [ +-- "Automotive Manufacturing", +-- "Agriculture", +-- "Mining", +-- "Technology", +-- "Aerospace" +-- ], +-- "agricultural_products": [ +-- "Poultry", +-- "Cotton", +-- "Peanuts", +-- "Soybeans", +-- "Corn" +-- ] +-- }, +-- "tourism": { +-- "attractions": [ +-- "U.S. Space & Rocket Center", +-- "Gulf Shores and Orange Beach", +-- "Rosa Parks Museum", +-- "Civil Rights Institute", +-- "Little River Canyon National Preserve" +-- ] +-- }, +-- "major_sports_teams": [ +-- "Alabama Crimson Tide (NCAA)", +-- "Auburn Tigers (NCAA)" +-- ] +-- }'), +-- ('US-AK', 'Alaska', 'us', '{ +-- "name": "Alaska", +-- "abbreviation": "AK", +-- "description": "Alaska is the largest state in the United States by area, known for its rugged and breathtaking natural beauty. It is situated in the northwesternmost region of North America and is bordered by Canada to the east, the Arctic Ocean to the north, and the Pacific Ocean to the west and south. Alaska is renowned for its diverse wildlife, glaciers, and majestic mountains. The state is sparsely populated, with the majority of its residents living in and around Anchorage and Fairbanks. Alaska''s economy is heavily dependent on oil and gas production, as well as fishing, tourism, and mining.", +-- "capital": "Juneau", +-- "largest_city": "Anchorage", +-- "area": { +-- "total": 663267, +-- "units": "square miles" +-- }, +-- "population": { +-- "estimate": 731158, +-- "year": 2020 +-- }, +-- "state_flower": "Forget-Me-Not", +-- "state_bird": "Willow Ptarmigan", +-- "state_tree": "Sitka Spruce", +-- "climate": { +-- "description": "Varies by region, with subarctic and arctic climates in the interior and north and more temperate maritime climates along the coast.", +-- "summer_highs": "50-70°F (varies by region)", +-- "winter_lows": "-40 to 20°F (varies by region)", +-- "precipitation": "Ranges from low in the interior to high along the coast" +-- }, +-- "economy": { +-- "industries": [ +-- "Oil and Gas", +-- "Fishing", +-- "Mining", +-- "Tourism", +-- "Forestry" +-- ], +-- "agricultural_products": [ +-- "Cattle", +-- "Hay", +-- "Vegetables", +-- "Barley", +-- "Dairy products" +-- ] +-- }, +-- "tourism": { +-- "attractions": [ +-- "Denali National Park", +-- "Glacier Bay National Park", +-- "Kenai Fjords National Park", +-- "Sitka National Historical Park", +-- "Anchorage Museum" +-- ] +-- }, +-- "major_sports_teams": [ +-- "Anchorage Wolverines (NAHL)", +-- "Alaska Aces (ECHL, formerly)" +-- ] +-- } +-- '), +-- ('US-AZ', 'Arizona', 'us', '{ +-- "name": "Arizona", +-- "abbreviation": "AZ", +-- "description": "Arizona is a state located in the southwestern region of the United States, known for its dramatic desert landscapes and vibrant history. The state is home to iconic landmarks such as the Grand Canyon and Monument Valley. Arizona''s diverse geography includes mountain ranges, forests, and high plateaus. The state has a warm desert climate in the southern and central areas and cooler mountain climates in the northern region. Arizona''s economy is driven by industries such as healthcare, technology, manufacturing, and tourism.", +-- "capital": "Phoenix", +-- "largest_city": "Phoenix", +-- "area": { +-- "total": 113990, +-- "units": "square miles" +-- }, +-- "population": { +-- "estimate": 7151502, +-- "year": 2020 +-- }, +-- "state_flower": "Saguaro Cactus Blossom", +-- "state_bird": "Cactus Wren", +-- "state_tree": "Palo Verde", +-- "climate": { +-- "description": "Mostly arid and semi-arid, with desert climates in the southern and central regions and temperate climates in the north.", +-- "summer_highs": "85-120°F (varies by region)", +-- "winter_lows": "30-60°F (varies by region)", +-- "precipitation": "Low in most areas, with higher amounts in mountain regions" +-- }, +-- "economy": { +-- "industries": [ +-- "Healthcare", +-- "Technology", +-- "Manufacturing", +-- "Tourism", +-- "Agriculture" +-- ], +-- "agricultural_products": [ +-- "Cattle", +-- "Dairy", +-- "Lettuce", +-- "Cotton", +-- "Alfalfa" +-- ] +-- }, +-- "tourism": { +-- "attractions": [ +-- "Grand Canyon National Park", +-- "Sedona", +-- "Monument Valley", +-- "Saguaro National Park", +-- "Petrified Forest National Park" +-- ] +-- }, +-- "major_sports_teams": [ +-- "Arizona Cardinals (NFL)", +-- "Phoenix Suns (NBA)", +-- "Arizona Diamondbacks (MLB)", +-- "Arizona Coyotes (NHL)" +-- ] +-- } +-- '), +-- ('US-AR', 'Arkansas', 'us', '{ +-- "name": "Arkansas", +-- "abbreviation": "AR", +-- "description": "Arkansas is a state located in the southeastern region of the United States, known for its natural beauty and diverse landscapes that include mountains, forests, and rivers. The state is nicknamed ''The Natural State'' due to its abundant natural resources and outdoor recreational opportunities. Arkansas has a rich history and played a significant role during the American Civil War. The state''s economy is driven by agriculture, manufacturing, and tourism, with key agricultural products including rice, poultry, and soybeans.", +-- "capital": "Little Rock", +-- "largest_city": "Little Rock", +-- "area": { +-- "total": 53179, +-- "units": "square miles" +-- }, +-- "population": { +-- "estimate": 3013756, +-- "year": 2020 +-- }, +-- "state_flower": "Apple Blossom", +-- "state_bird": "Northern Mockingbird", +-- "state_tree": "Pine", +-- "climate": { +-- "description": "Humid subtropical climate, with hot summers and mild winters.", +-- "summer_highs": "80-90°F", +-- "winter_lows": "20-40°F", +-- "precipitation": "High, especially in the spring" +-- }, +-- "economy": { +-- "industries": [ +-- "Agriculture", +-- "Manufacturing", +-- "Retail", +-- "Tourism", +-- "Education" +-- ], +-- "agricultural_products": [ +-- "Rice", +-- "Poultry", +-- "Soybeans", +-- "Cotton", +-- "Catfish" +-- ] +-- }, +-- "tourism": { +-- "attractions": [ +-- "Hot Springs National Park", +-- "Buffalo National River", +-- "Crater of Diamonds State Park", +-- "Little Rock Central High School National Historic Site", +-- "Ozark National Forest" +-- ] +-- }, +-- "major_sports_teams": [ +-- "Arkansas Razorbacks (NCAA)" +-- ] +-- } +-- '), +INSERT INTO "worldTravelCountryRegions" (id, name, country_code) VALUES ('US-AL', 'Alabama', 'us'), ('US-AK', 'Alaska', 'us'), ('US-AZ', 'Arizona', 'us'), diff --git a/src/app.html b/src/app.html index d45252a..0efe6e0 100644 --- a/src/app.html +++ b/src/app.html @@ -1,5 +1,5 @@ - +
diff --git a/src/hooks.server.ts b/src/hooks.server.ts index 4b48cbc..09bd7ea 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -1,7 +1,8 @@ import { lucia } from "$lib/server/auth"; import type { Handle } from "@sveltejs/kit"; +import { sequence } from '@sveltejs/kit/hooks'; -export const handle: Handle = async ({ event, resolve }) => { +export const authHook: Handle = async ({ event, resolve }) => { const sessionId = event.cookies.get(lucia.sessionCookieName); if (!sessionId) { event.locals.user = null; @@ -20,7 +21,7 @@ export const handle: Handle = async ({ event, resolve }) => { }); } if (!session) { - const sessionCookie = lucia.createBlankSessionCookie(); + const sessionCookie:any = lucia.createBlankSessionCookie(); event.cookies.set(sessionCookie.name, sessionCookie.value, { path: ".", ...sessionCookie.attributes, @@ -30,3 +31,26 @@ export const handle: Handle = async ({ event, resolve }) => { event.locals.session = session; return resolve(event); }; + +export const themeHook: Handle = async ({ event, resolve }) => { + let theme:String | null = null; + + const newTheme = event.url.searchParams.get("theme"); + const cookieTheme = event.cookies.get("colortheme"); + + if(newTheme) { + theme = newTheme; + } else if (cookieTheme) { + theme = cookieTheme; + } + if (theme) { + return await resolve(event, { + transformPageChunk: ({ html }) => + html.replace('data-theme=""', `data-theme="${theme}"`) + }) + } + + return await resolve(event); +} + +export const handle = sequence(authHook, themeHook); diff --git a/src/lib/components/AdventureCard.svelte b/src/lib/components/AdventureCard.svelte index c88d253..357635d 100644 --- a/src/lib/components/AdventureCard.svelte +++ b/src/lib/components/AdventureCard.svelte @@ -2,6 +2,7 @@ import { createEventDispatcher } from "svelte"; import locationDot from "$lib/assets/locationDot.svg"; import calendar from "$lib/assets/calendar.svg"; + import { goto } from "$app/navigation"; const dispatch = createEventDispatcher(); export let type: String; @@ -12,6 +13,7 @@ export let id: Number | undefined = undefined; export let regionId: String | undefined = undefined; export let visited: Boolean | undefined = undefined; + export let countryCode: String | undefined = undefined; function remove() { dispatch("remove", id); @@ -30,11 +32,15 @@ dispatch("removeVisit", regionId); visited = false; } + + function moreInfo() { + goto(`/worldtravel/${countryCode}/${regionId}`); + } {#if type === "mylog"}{regionId}