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"}

{name}

@@ -66,7 +72,7 @@ {#if type === "featured"}

{name}

@@ -88,7 +94,7 @@ {#if type === "shared"}

{name}

@@ -116,12 +122,13 @@ {#if type === "worldtravelregion"}

{name}

{regionId}

+ {#if !visited} { + const theme = action.searchParams.get("theme"); + if (theme) { + document.documentElement.setAttribute("data-theme", theme); + } + }; + let count = 0; let infoModalOpen = false; @@ -97,5 +105,22 @@ {/if} +
diff --git a/src/lib/components/UserAvatar.svelte b/src/lib/components/UserAvatar.svelte index 133562b..ba5628a 100644 --- a/src/lib/components/UserAvatar.svelte +++ b/src/lib/components/UserAvatar.svelte @@ -37,8 +37,8 @@
  • Profile
  • -
    -
  • + +
  • diff --git a/src/lib/components/maps/US.svelte b/src/lib/components/maps/US.svelte new file mode 100644 index 0000000..7b24e5d --- /dev/null +++ b/src/lib/components/maps/US.svelte @@ -0,0 +1,880 @@ + + + + + + + + + handleStateClick("US-AL")} + > + + + + handleStateClick("US-AK")} + > + + + + handleStateClick("US-AZ")} + > + + + + handleStateClick("US-AR")} + > + + + + handleStateClick("US-CA")} + > + + + + handleStateClick("US-CO")} + > + + + + handleStateClick("US-CT")} + > + + + + + + handleStateClick("US-DE")} + > + + + + + + handleStateClick("US-FL")} + > + + + + handleStateClick("US-GA")} + > + + + + handleStateClick("US-HI")} + > + + + + handleStateClick("US-ID")} + > + + + + handleStateClick("US-IL")} + > + + + + handleStateClick("US-IN")} + > + + + + handleStateClick("US-IA")} + > + + + + handleStateClick("US-KS")} + > + + + + handleStateClick("US-KY")} + > + + + + handleStateClick("US-LA")} + > + + + + handleStateClick("US-ME")} + > + + + + handleStateClick("US-MD")} + > + + + + + + handleStateClick("US-MA")} + > + + + + + + handleStateClick("US-MI")} + > + + + + + handleStateClick("US-MN")} + > + + + + handleStateClick("US-MS")} + > + + + + handleStateClick("US-MO")} + > + + + + handleStateClick("US-MT")} + > + + + + handleStateClick("US-NE")} + > + + + + handleStateClick("US-NV")} + > + + + + handleStateClick("US-NH")} + > + + + + + + handleStateClick("US-NJ")} + > + + + + + + handleStateClick("US-NM")} + > + + + + handleStateClick("US-NY")} + > + + + + handleStateClick("US-NC")} + > + + + + handleStateClick("US-ND")} + > + + + + handleStateClick("US-OH")} + > + + + + handleStateClick("US-OK")} + > + + + + handleStateClick("US-OR")} + > + + + + handleStateClick("US-PA")} + > + + + + handleStateClick("US-RI")} + > + + + + + + handleStateClick("US-SC")} + > + + + + handleStateClick("US-SD")} + > + + + + handleStateClick("US-TN")} + > + + + + handleStateClick("US-TX")} + > + + + + handleStateClick("US-UT")} + > + + + + handleStateClick("US-VT")} + > + + + + + + handleStateClick("US-VA")} + > + + + + handleStateClick("US-WA")} + > + + + + handleStateClick("US-WV")} + > + + + + handleStateClick("US-WI")} + > + + + + handleStateClick("US-WY")} + > + + + + + + + diff --git a/src/lib/db/schema.ts b/src/lib/db/schema.ts index 2167882..303f47f 100644 --- a/src/lib/db/schema.ts +++ b/src/lib/db/schema.ts @@ -66,10 +66,14 @@ export const worldTravelCountryRegions = pgTable("worldTravelCountryRegions", { country_code: text("country_code") .notNull() .references(() => worldTravelCountries.country_code), + info: json("info"), }); export const userVisitedWorldTravel = pgTable("userVisitedWorldTravel", { id: serial("id").primaryKey(), + country_code: text("country_code") + .notNull() + .references(() => worldTravelCountries.country_code), userId: text("user_id") .notNull() .references(() => userTable.id), diff --git a/src/lib/utils/types.ts b/src/lib/utils/types.ts index 39cb486..645621c 100644 --- a/src/lib/utils/types.ts +++ b/src/lib/utils/types.ts @@ -4,3 +4,36 @@ export interface Adventure { location: string; created: string; } + +export interface RegionInfo { + name: string; + abbreviation: string; + description: string; + capital: string; + largest_city: string; + area: { + total: number; + units: string; + }; + population: { + estimate: number; + year: number; + }; + state_flower: string; + state_bird: string; + state_tree: string; + climate: { + description: string; + summer_highs: string; + winter_lows: string; + precipitation: string; + }; + economy: { + industries: string[]; + agricultural_products: string[]; + }; + tourism: { + attractions: string[]; + }; + major_sports_teams: string[]; +}; diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index abcd0fc..22582f2 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -2,8 +2,8 @@ export let data; import Footer from "$lib/components/Footer.svelte"; import Navbar from "$lib/components/Navbar.svelte"; + import type { SubmitFunction } from "@sveltejs/kit"; import "../app.css"; - // only show footer if scrolled to the bottom diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 4838575..e007790 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -3,7 +3,7 @@ import { fail, redirect } from "@sveltejs/kit"; import type { Actions, PageServerLoad } from "./$types"; -export const load: PageServerLoad = async (event) => { +export const load: PageServerLoad = async (event: { locals: { user: any; }; }) => { if (event.locals.user) return { user: event.locals.user, @@ -15,7 +15,7 @@ export const load: PageServerLoad = async (event) => { // handle the logout action export const actions: Actions = { - default: async (event) => { + logout: async (event) => { if (!event.locals.session) { return fail(401); } @@ -28,4 +28,14 @@ export const actions: Actions = { }); return redirect(302, "/login"); }, + setTheme: async ( { url, cookies }) => { + const theme = url.searchParams.get("theme"); + // change the theme only if it is one of the allowed themes + if (theme && ["light", "dark", "night", "retro", "forest", "nord"].includes(theme)) { + cookies.set("colortheme", theme, { + path: "/", + maxAge: 60 * 60 * 24 * 365, + }); + } + }, }; diff --git a/src/routes/api/regionvisit/+server.ts b/src/routes/api/regionvisit/+server.ts index b28b75a..0c18c19 100644 --- a/src/routes/api/regionvisit/+server.ts +++ b/src/routes/api/regionvisit/+server.ts @@ -18,6 +18,7 @@ export async function POST(event: RequestEvent): Promise { .values({ userId: event.locals.user.id, region_id: body.region_id, + country_code: body.country_code, }) .execute(); return new Response(JSON.stringify({ res: res }), { diff --git a/src/routes/log/+page.svelte b/src/routes/log/+page.svelte index af7b1b6..ee9db94 100644 --- a/src/routes/log/+page.svelte +++ b/src/routes/log/+page.svelte @@ -6,7 +6,6 @@ import AdventureCard from "$lib/components/AdventureCard.svelte"; import type { Adventure } from "$lib/utils/types"; import { onMount } from "svelte"; - import { exportData } from "../../services/export"; import exportFile from "$lib/assets/exportFile.svg"; import deleteIcon from "$lib/assets/deleteIcon.svg"; import SucessToast from "$lib/components/SucessToast.svelte"; @@ -48,6 +47,18 @@ }, 3000); } + function exportData() { + let jsonString = JSON.stringify(adventures); + let blob = new Blob([jsonString], { type: "application/json" }); + let url = URL.createObjectURL(blob); + + let link = document.createElement("a"); + link.download = "adventurelog-export.json"; + link.href = url; + link.click(); + URL.revokeObjectURL(url); + } + const createNewAdventure = () => { let currentDate = new Date(); let dateString = currentDate.toISOString().slice(0, 10); // Get date in "yyyy-mm-dd" format @@ -290,12 +301,7 @@
    -