mirror of
https://github.com/seanmorley15/AdventureLog.git
synced 2025-07-31 02:39:38 +02:00
Refactor database schema and add planner functionality
This commit is contained in:
parent
3072fedccf
commit
b2184bdee3
17 changed files with 1593 additions and 14 deletions
13
migrations/0004_noisy_squadron_supreme.sql
Normal file
13
migrations/0004_noisy_squadron_supreme.sql
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
CREATE TABLE IF NOT EXISTS "userPlannedAdventures" (
|
||||||
|
"id" serial PRIMARY KEY NOT NULL,
|
||||||
|
"user_id" text NOT NULL,
|
||||||
|
"adventure_name" text NOT NULL,
|
||||||
|
"location" text,
|
||||||
|
"activity_types" text
|
||||||
|
);
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "userPlannedAdventures" ADD CONSTRAINT "userPlannedAdventures_user_id_user_id_fk" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
1
migrations/0005_massive_black_tarantula.sql
Normal file
1
migrations/0005_massive_black_tarantula.sql
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE "userPlannedAdventures" ALTER COLUMN "activity_types" SET DATA TYPE json;
|
10
migrations/0006_colorful_inertia.sql
Normal file
10
migrations/0006_colorful_inertia.sql
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
ALTER TABLE "userPlannedAdventures" RENAME COLUMN "user_id" TO "userId";--> statement-breakpoint
|
||||||
|
ALTER TABLE "userPlannedAdventures" RENAME COLUMN "adventure_name" TO "adventureName";--> statement-breakpoint
|
||||||
|
ALTER TABLE "userPlannedAdventures" RENAME COLUMN "activity_types" TO "activityTypes";--> statement-breakpoint
|
||||||
|
ALTER TABLE "userPlannedAdventures" DROP CONSTRAINT "userPlannedAdventures_user_id_user_id_fk";
|
||||||
|
--> statement-breakpoint
|
||||||
|
DO $$ BEGIN
|
||||||
|
ALTER TABLE "userPlannedAdventures" ADD CONSTRAINT "userPlannedAdventures_userId_user_id_fk" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE no action ON UPDATE no action;
|
||||||
|
EXCEPTION
|
||||||
|
WHEN duplicate_object THEN null;
|
||||||
|
END $$;
|
463
migrations/meta/0004_snapshot.json
Normal file
463
migrations/meta/0004_snapshot.json
Normal file
|
@ -0,0 +1,463 @@
|
||||||
|
{
|
||||||
|
"id": "4ed4f0d5-7731-49a1-ab2f-9af3aad2c95c",
|
||||||
|
"prevId": "72cc9a9a-a12e-4ca2-b644-b704673af4d7",
|
||||||
|
"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": {}
|
||||||
|
},
|
||||||
|
"userPlannedAdventures": {
|
||||||
|
"name": "userPlannedAdventures",
|
||||||
|
"schema": "",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "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
|
||||||
|
},
|
||||||
|
"activity_types": {
|
||||||
|
"name": "activity_types",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {
|
||||||
|
"userPlannedAdventures_user_id_user_id_fk": {
|
||||||
|
"name": "userPlannedAdventures_user_id_user_id_fk",
|
||||||
|
"tableFrom": "userPlannedAdventures",
|
||||||
|
"tableTo": "user",
|
||||||
|
"columnsFrom": [
|
||||||
|
"user_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "no action",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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
|
||||||
|
},
|
||||||
|
"signup_date": {
|
||||||
|
"name": "signup_date",
|
||||||
|
"type": "timestamp with time zone",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"last_login": {
|
||||||
|
"name": "last_login",
|
||||||
|
"type": "timestamp with time zone",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"role": {
|
||||||
|
"name": "role",
|
||||||
|
"type": "text",
|
||||||
|
"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": {}
|
||||||
|
}
|
||||||
|
}
|
463
migrations/meta/0005_snapshot.json
Normal file
463
migrations/meta/0005_snapshot.json
Normal file
|
@ -0,0 +1,463 @@
|
||||||
|
{
|
||||||
|
"id": "f3c33262-0fe7-4b0f-8522-82e337da26d5",
|
||||||
|
"prevId": "4ed4f0d5-7731-49a1-ab2f-9af3aad2c95c",
|
||||||
|
"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": {}
|
||||||
|
},
|
||||||
|
"userPlannedAdventures": {
|
||||||
|
"name": "userPlannedAdventures",
|
||||||
|
"schema": "",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "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
|
||||||
|
},
|
||||||
|
"activity_types": {
|
||||||
|
"name": "activity_types",
|
||||||
|
"type": "json",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {
|
||||||
|
"userPlannedAdventures_user_id_user_id_fk": {
|
||||||
|
"name": "userPlannedAdventures_user_id_user_id_fk",
|
||||||
|
"tableFrom": "userPlannedAdventures",
|
||||||
|
"tableTo": "user",
|
||||||
|
"columnsFrom": [
|
||||||
|
"user_id"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "no action",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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
|
||||||
|
},
|
||||||
|
"signup_date": {
|
||||||
|
"name": "signup_date",
|
||||||
|
"type": "timestamp with time zone",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"last_login": {
|
||||||
|
"name": "last_login",
|
||||||
|
"type": "timestamp with time zone",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"role": {
|
||||||
|
"name": "role",
|
||||||
|
"type": "text",
|
||||||
|
"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": {}
|
||||||
|
}
|
||||||
|
}
|
463
migrations/meta/0006_snapshot.json
Normal file
463
migrations/meta/0006_snapshot.json
Normal file
|
@ -0,0 +1,463 @@
|
||||||
|
{
|
||||||
|
"id": "42010132-1400-4431-800b-7ecd45c7aa9a",
|
||||||
|
"prevId": "f3c33262-0fe7-4b0f-8522-82e337da26d5",
|
||||||
|
"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": {}
|
||||||
|
},
|
||||||
|
"userPlannedAdventures": {
|
||||||
|
"name": "userPlannedAdventures",
|
||||||
|
"schema": "",
|
||||||
|
"columns": {
|
||||||
|
"id": {
|
||||||
|
"name": "id",
|
||||||
|
"type": "serial",
|
||||||
|
"primaryKey": true,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"userId": {
|
||||||
|
"name": "userId",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"adventureName": {
|
||||||
|
"name": "adventureName",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"location": {
|
||||||
|
"name": "location",
|
||||||
|
"type": "text",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"activityTypes": {
|
||||||
|
"name": "activityTypes",
|
||||||
|
"type": "json",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"indexes": {},
|
||||||
|
"foreignKeys": {
|
||||||
|
"userPlannedAdventures_userId_user_id_fk": {
|
||||||
|
"name": "userPlannedAdventures_userId_user_id_fk",
|
||||||
|
"tableFrom": "userPlannedAdventures",
|
||||||
|
"tableTo": "user",
|
||||||
|
"columnsFrom": [
|
||||||
|
"userId"
|
||||||
|
],
|
||||||
|
"columnsTo": [
|
||||||
|
"id"
|
||||||
|
],
|
||||||
|
"onDelete": "no action",
|
||||||
|
"onUpdate": "no action"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"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
|
||||||
|
},
|
||||||
|
"signup_date": {
|
||||||
|
"name": "signup_date",
|
||||||
|
"type": "timestamp with time zone",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": true
|
||||||
|
},
|
||||||
|
"last_login": {
|
||||||
|
"name": "last_login",
|
||||||
|
"type": "timestamp with time zone",
|
||||||
|
"primaryKey": false,
|
||||||
|
"notNull": false
|
||||||
|
},
|
||||||
|
"role": {
|
||||||
|
"name": "role",
|
||||||
|
"type": "text",
|
||||||
|
"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": {}
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,6 +29,27 @@
|
||||||
"when": 1713402092365,
|
"when": 1713402092365,
|
||||||
"tag": "0003_easy_iron_monger",
|
"tag": "0003_easy_iron_monger",
|
||||||
"breakpoints": true
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 4,
|
||||||
|
"version": "5",
|
||||||
|
"when": 1713737819317,
|
||||||
|
"tag": "0004_noisy_squadron_supreme",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 5,
|
||||||
|
"version": "5",
|
||||||
|
"when": 1713738940329,
|
||||||
|
"tag": "0005_massive_black_tarantula",
|
||||||
|
"breakpoints": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"idx": 6,
|
||||||
|
"version": "5",
|
||||||
|
"when": 1713739045755,
|
||||||
|
"tag": "0006_colorful_inertia",
|
||||||
|
"breakpoints": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -14,6 +14,7 @@
|
||||||
export let regionId: String | undefined = undefined;
|
export let regionId: String | undefined = undefined;
|
||||||
export let visited: Boolean | undefined = undefined;
|
export let visited: Boolean | undefined = undefined;
|
||||||
export let countryCode: String | undefined = undefined;
|
export let countryCode: String | undefined = undefined;
|
||||||
|
export let activityTypes: String[] | undefined = undefined;
|
||||||
|
|
||||||
function remove() {
|
function remove() {
|
||||||
dispatch("remove", id);
|
dispatch("remove", id);
|
||||||
|
@ -126,3 +127,25 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if type === "planner"}
|
||||||
|
<div
|
||||||
|
class="card min-w-max lg:w-96 md:w-80 sm:w-60 xs:w-40 bg-primary-content shadow-xl overflow-hidden text-base-content"
|
||||||
|
>
|
||||||
|
<div class="card-body">
|
||||||
|
<h2 class="card-title overflow-ellipsis">{name}</h2>
|
||||||
|
{#if location != ""}
|
||||||
|
<div class="inline-flex items-center">
|
||||||
|
<iconify-icon icon="mdi:map-marker" class="text-xl"></iconify-icon>
|
||||||
|
<p class="ml-.5">{location}</p>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
{#if activityTypes && activityTypes.length > 0}
|
||||||
|
<p>{activityTypes}</p>
|
||||||
|
{/if}
|
||||||
|
<div class="card-actions justify-end">
|
||||||
|
<button class="btn btn-primary" on:click={add}>Add</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
|
@ -78,6 +78,10 @@
|
||||||
<button class="btn btn-primary my-2 md:my-0 md:mr-4" on:click={goToLog}
|
<button class="btn btn-primary my-2 md:my-0 md:mr-4" on:click={goToLog}
|
||||||
>My Log</button
|
>My Log</button
|
||||||
>
|
>
|
||||||
|
<button
|
||||||
|
class="btn btn-primary my-2 md:my-0 md:mr-4"
|
||||||
|
on:click={() => goto("/planner")}>Planner</button
|
||||||
|
>
|
||||||
{/if}
|
{/if}
|
||||||
<button
|
<button
|
||||||
class="btn btn-primary my-2 md:my-0 md:mr-4"
|
class="btn btn-primary my-2 md:my-0 md:mr-4"
|
||||||
|
|
|
@ -89,4 +89,14 @@ export const userVisitedWorldTravel = pgTable("userVisitedWorldTravel", {
|
||||||
region_id: varchar("region_id")
|
region_id: varchar("region_id")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => worldTravelCountryRegions.id),
|
.references(() => worldTravelCountryRegions.id),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const userPlannedAdventures = pgTable("userPlannedAdventures", {
|
||||||
|
id: serial("id").primaryKey(),
|
||||||
|
userId: text("userId")
|
||||||
|
.notNull()
|
||||||
|
.references(() => userTable.id),
|
||||||
|
name: text("adventureName").notNull(),
|
||||||
|
location: text("location"),
|
||||||
|
activityTypes: json("activityTypes"),
|
||||||
|
});
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
export interface Adventure {
|
export interface Adventure {
|
||||||
id: number;
|
id?: number;
|
||||||
name: string;
|
name?: string;
|
||||||
location: string;
|
location?: string | undefined;
|
||||||
created: string;
|
created?: string | undefined;
|
||||||
|
description?: string | undefined;
|
||||||
|
activityTypes?: string[] | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface RegionInfo {
|
export interface RegionInfo {
|
||||||
|
@ -36,4 +38,4 @@ export interface RegionInfo {
|
||||||
attractions: string[];
|
attractions: string[];
|
||||||
};
|
};
|
||||||
major_sports_teams: string[];
|
major_sports_teams: string[];
|
||||||
};
|
}
|
||||||
|
|
|
@ -135,10 +135,10 @@
|
||||||
(adventure) => adventure.id === event.detail
|
(adventure) => adventure.id === event.detail
|
||||||
);
|
);
|
||||||
if (adventure) {
|
if (adventure) {
|
||||||
editId = adventure.id;
|
editId = adventure.id || 0;
|
||||||
editName = adventure.name;
|
editName = adventure.name || "";
|
||||||
editLocation = adventure.location;
|
editLocation = adventure.location || "";
|
||||||
editCreated = adventure.created;
|
editCreated = adventure.created || "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
21
src/routes/planner/+page.server.ts
Normal file
21
src/routes/planner/+page.server.ts
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
import { db } from "$lib/db/db.server";
|
||||||
|
import { userPlannedAdventures } from "$lib/db/schema";
|
||||||
|
import { eq } from "drizzle-orm";
|
||||||
|
import type { LayoutServerLoad } from "../$types";
|
||||||
|
import { redirect } from "@sveltejs/kit";
|
||||||
|
|
||||||
|
export const load: LayoutServerLoad = async (event) => {
|
||||||
|
if (event.locals.user) {
|
||||||
|
let plannedAdventures = await db
|
||||||
|
.select()
|
||||||
|
.from(userPlannedAdventures)
|
||||||
|
.where(eq(userPlannedAdventures.userId, event.locals.user.id));
|
||||||
|
return {
|
||||||
|
user: event.locals.user,
|
||||||
|
isServerSetup: event.locals.isServerSetup,
|
||||||
|
plannedAdventures,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return redirect(302, "/login");
|
||||||
|
}
|
||||||
|
};
|
29
src/routes/planner/+page.svelte
Normal file
29
src/routes/planner/+page.svelte
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import { page } from "$app/stores";
|
||||||
|
import type { Adventure } from "$lib/utils/types";
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import AdventureCard from "$lib/components/AdventureCard.svelte";
|
||||||
|
|
||||||
|
let plannedAdventures: Adventure[] = [];
|
||||||
|
|
||||||
|
onMount(async () => {
|
||||||
|
plannedAdventures = $page.data.plannedAdventures;
|
||||||
|
console.log(plannedAdventures);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<h1 class="font-extrabold text-center text-4xl">My Planned Adventures</h1>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="grid xl:grid-cols-3 lg:grid-cols-3 md:grid-cols-2 sm:grid-cols-1 gap-4 mt-4 content-center auto-cols-auto ml-6 mr-6"
|
||||||
|
>
|
||||||
|
{#each plannedAdventures as adventure (adventure.id)}
|
||||||
|
<AdventureCard
|
||||||
|
type="planner"
|
||||||
|
id={adventure.id}
|
||||||
|
name={adventure.name}
|
||||||
|
location={adventure.location}
|
||||||
|
activityTypes={adventure.activityTypes}
|
||||||
|
/>
|
||||||
|
{/each}
|
||||||
|
</div>
|
|
@ -1,11 +1,20 @@
|
||||||
import { error, redirect, type Actions, type Handle } from "@sveltejs/kit";
|
import { error, redirect, type Actions, type Handle } from "@sveltejs/kit";
|
||||||
import type { PageServerLoad } from "./$types";
|
import type { PageServerLoad } from "./$types";
|
||||||
import { db } from "$lib/db/db.server";
|
import { db } from "$lib/db/db.server";
|
||||||
import { sessionTable, userTable } from "$lib/db/schema";
|
import {
|
||||||
|
sessionTable,
|
||||||
|
userTable,
|
||||||
|
userVisitedAdventures,
|
||||||
|
userVisitedWorldTravel,
|
||||||
|
} from "$lib/db/schema";
|
||||||
import type { DatabaseUser } from "$lib/server/auth";
|
import type { DatabaseUser } from "$lib/server/auth";
|
||||||
|
import { count } from "drizzle-orm";
|
||||||
|
|
||||||
export const load: PageServerLoad = async (event) => {
|
export const load: PageServerLoad = async (event) => {
|
||||||
let users: DatabaseUser[] = [];
|
let users: DatabaseUser[] = [];
|
||||||
|
let visitCount: number = NaN;
|
||||||
|
let userCount: number = NaN;
|
||||||
|
let regionCount: number = NaN;
|
||||||
if (!event.locals.user) {
|
if (!event.locals.user) {
|
||||||
return redirect(302, "/login");
|
return redirect(302, "/login");
|
||||||
}
|
}
|
||||||
|
@ -14,9 +23,24 @@ export const load: PageServerLoad = async (event) => {
|
||||||
}
|
}
|
||||||
if (event.locals.user.role === "admin") {
|
if (event.locals.user.role === "admin") {
|
||||||
users = (await db.select().from(userTable).execute()) as DatabaseUser[];
|
users = (await db.select().from(userTable).execute()) as DatabaseUser[];
|
||||||
|
visitCount = (await db
|
||||||
|
.select({ count: count() })
|
||||||
|
.from(userVisitedAdventures)
|
||||||
|
.execute()) as unknown as number;
|
||||||
|
userCount = (await db
|
||||||
|
.select({ count: count() })
|
||||||
|
.from(userTable)
|
||||||
|
.execute()) as unknown as number;
|
||||||
|
regionCount = (await db
|
||||||
|
.select({ count: count() })
|
||||||
|
.from(userVisitedWorldTravel)
|
||||||
|
.execute()) as unknown as number;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
users,
|
users,
|
||||||
|
visitCount,
|
||||||
|
userCount,
|
||||||
|
regionCount,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -58,12 +58,16 @@
|
||||||
console.log(errors);
|
console.log(errors);
|
||||||
cancel();
|
cancel();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
let visitCount = $page.data.visitCount[0].count;
|
||||||
|
let userCount = $page.data.userCount[0].count;
|
||||||
|
let regionCount = $page.data.regionCount[0].count;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h1 class="text-center font-extrabold text-4xl">Admin Settings</h1>
|
<h1 class="text-center font-extrabold text-4xl">Admin Settings</h1>
|
||||||
|
|
||||||
<h2 class="text-center font-extrabold text-2xl">Add User</h2>
|
<h2 class="text-center font-extrabold text-2xl">Add User</h2>
|
||||||
<div class="flex justify-center">
|
<div class="flex justify-center mb-4">
|
||||||
<form
|
<form
|
||||||
method="POST"
|
method="POST"
|
||||||
action="/signup"
|
action="/signup"
|
||||||
|
@ -125,7 +129,7 @@
|
||||||
|
|
||||||
<h2 class="text-center font-extrabold text-2xl">User Managment</h2>
|
<h2 class="text-center font-extrabold text-2xl">User Managment</h2>
|
||||||
<div
|
<div
|
||||||
class="grid xl:grid-cols-3 lg:grid-cols-3 md:grid-cols-2 sm:grid-cols-1 gap-4 mt-4 content-center auto-cols-auto ml-6 mr-6"
|
class="grid xl:grid-cols-3 lg:grid-cols-3 md:grid-cols-2 sm:grid-cols-1 gap-4 mt-4 content-center auto-cols-auto ml-6 mr-6 mb-4"
|
||||||
>
|
>
|
||||||
{#each $page.data.users as user}
|
{#each $page.data.users as user}
|
||||||
<div>
|
<div>
|
||||||
|
@ -143,3 +147,31 @@
|
||||||
message="Are you sure you want to clear all user sessions?"
|
message="Are you sure you want to clear all user sessions?"
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
<h2 class="text-center font-extrabold text-2xl">Admin Stats (All Users)</h2>
|
||||||
|
<div class="flex items-center justify-center mb-4">
|
||||||
|
<div class="stats stats-vertical lg:stats-horizontal shadow">
|
||||||
|
<div class="stat">
|
||||||
|
<div class="stat-title">Total Visits</div>
|
||||||
|
<div class="stat-value">{visitCount}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="stat">
|
||||||
|
<div class="stat-title">Total Users</div>
|
||||||
|
<div class="stat-value">{userCount}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="stat">
|
||||||
|
<div class="stat-title">Visited Regions</div>
|
||||||
|
<div class="stat-value">{regionCount}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<svelte:head>
|
||||||
|
<title>Admin Settings | AdventureLog</title>
|
||||||
|
<meta
|
||||||
|
name="description"
|
||||||
|
content="Admin Settings for AdventureLog. Add users, manage sessions, and more!"
|
||||||
|
/>
|
||||||
|
</svelte:head>
|
||||||
|
|
|
@ -32,4 +32,4 @@
|
||||||
name="description"
|
name="description"
|
||||||
content="Explore the world and add countries to your visited list!"
|
content="Explore the world and add countries to your visited list!"
|
||||||
/>
|
/>
|
||||||
</svelte:head>;
|
</svelte:head>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue