From 617ecab044f0f6cd5640b81de814ba2e756cd31a Mon Sep 17 00:00:00 2001 From: SHYAKA Davis <87414827+shyakadavis@users.noreply.github.com> Date: Mon, 8 Jul 2024 18:02:06 +0200 Subject: [PATCH] chore: add 300 riddles (ibisakuzo) (#40) Co-authored-by: Davis SHYAKA <87414827+davis-shyaka@users.noreply.github.com> --- .../migrations/0022_legal_the_santerians.sql | 2 + src/db/migrations/0023_equal_betty_brant.sql | 2 + src/db/migrations/0024_black_white_queen.sql | 1 + src/db/migrations/0025_wise_ironclad.sql | 1 + src/db/migrations/0026_gorgeous_speed.sql | 1 + src/db/migrations/meta/0022_snapshot.json | 904 ++++++++++++++++++ src/db/migrations/meta/0023_snapshot.json | 904 ++++++++++++++++++ src/db/migrations/meta/0024_snapshot.json | 904 ++++++++++++++++++ src/db/migrations/meta/0025_snapshot.json | 904 ++++++++++++++++++ src/db/migrations/meta/0026_snapshot.json | 904 ++++++++++++++++++ src/db/migrations/meta/_journal.json | 35 + src/db/schemas/riddles.ts | 8 +- src/scripts/populate.ts | 58 ++ 13 files changed, 4624 insertions(+), 4 deletions(-) create mode 100644 src/db/migrations/0022_legal_the_santerians.sql create mode 100644 src/db/migrations/0023_equal_betty_brant.sql create mode 100644 src/db/migrations/0024_black_white_queen.sql create mode 100644 src/db/migrations/0025_wise_ironclad.sql create mode 100644 src/db/migrations/0026_gorgeous_speed.sql create mode 100644 src/db/migrations/meta/0022_snapshot.json create mode 100644 src/db/migrations/meta/0023_snapshot.json create mode 100644 src/db/migrations/meta/0024_snapshot.json create mode 100644 src/db/migrations/meta/0025_snapshot.json create mode 100644 src/db/migrations/meta/0026_snapshot.json create mode 100644 src/scripts/populate.ts diff --git a/src/db/migrations/0022_legal_the_santerians.sql b/src/db/migrations/0022_legal_the_santerians.sql new file mode 100644 index 0000000..13ec7fc --- /dev/null +++ b/src/db/migrations/0022_legal_the_santerians.sql @@ -0,0 +1,2 @@ +ALTER TABLE "riddles" ALTER COLUMN "categories" DROP NOT NULL;--> statement-breakpoint +ALTER TABLE "riddles" ALTER COLUMN "hints" DROP NOT NULL; \ No newline at end of file diff --git a/src/db/migrations/0023_equal_betty_brant.sql b/src/db/migrations/0023_equal_betty_brant.sql new file mode 100644 index 0000000..53a4648 --- /dev/null +++ b/src/db/migrations/0023_equal_betty_brant.sql @@ -0,0 +1,2 @@ +ALTER TABLE "riddles" ALTER COLUMN "question" SET DATA TYPE varchar(64);--> statement-breakpoint +ALTER TABLE "riddles" ALTER COLUMN "answer" SET DATA TYPE varchar(32); \ No newline at end of file diff --git a/src/db/migrations/0024_black_white_queen.sql b/src/db/migrations/0024_black_white_queen.sql new file mode 100644 index 0000000..89fcb6c --- /dev/null +++ b/src/db/migrations/0024_black_white_queen.sql @@ -0,0 +1 @@ +ALTER TABLE "riddles" ALTER COLUMN "hints" SET DATA TYPE varchar(16)[]; \ No newline at end of file diff --git a/src/db/migrations/0025_wise_ironclad.sql b/src/db/migrations/0025_wise_ironclad.sql new file mode 100644 index 0000000..f16f967 --- /dev/null +++ b/src/db/migrations/0025_wise_ironclad.sql @@ -0,0 +1 @@ +ALTER TABLE "riddles" ALTER COLUMN "question" SET DATA TYPE varchar(128); \ No newline at end of file diff --git a/src/db/migrations/0026_gorgeous_speed.sql b/src/db/migrations/0026_gorgeous_speed.sql new file mode 100644 index 0000000..7fbb3d8 --- /dev/null +++ b/src/db/migrations/0026_gorgeous_speed.sql @@ -0,0 +1 @@ +ALTER TABLE "riddles" ALTER COLUMN "answer" SET DATA TYPE varchar(64); \ No newline at end of file diff --git a/src/db/migrations/meta/0022_snapshot.json b/src/db/migrations/meta/0022_snapshot.json new file mode 100644 index 0000000..cca8e9f --- /dev/null +++ b/src/db/migrations/meta/0022_snapshot.json @@ -0,0 +1,904 @@ +{ + "id": "9996bcf9-18a9-4caa-9081-ed55005ca0b1", + "prevId": "8505dd89-f9d2-4495-9ab8-0e3b646899a0", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.categories": { + "name": "categories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "categories_name_index": { + "name": "categories_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "categories_name_unique": { + "name": "categories_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.cells": { + "name": "cells", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "sector_id": { + "name": "sector_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cells_name_index": { + "name": "cells_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cells_sector_id_sectors_id_fk": { + "name": "cells_sector_id_sectors_id_fk", + "tableFrom": "cells", + "tableTo": "sectors", + "columnsFrom": ["sector_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.districts": { + "name": "districts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "province_id": { + "name": "province_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "districts_name_index": { + "name": "districts_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "districts_province_id_provinces_id_fk": { + "name": "districts_province_id_provinces_id_fk", + "tableFrom": "districts", + "tableTo": "provinces", + "columnsFrom": ["province_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "districts_name_unique": { + "name": "districts_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.mountains": { + "name": "mountains", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "elevation": { + "name": "elevation", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "native_name": { + "name": "native_name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false + }, + "hints": { + "name": "hints", + "type": "varchar(16)[]", + "primaryKey": false, + "notNull": false + }, + "location": { + "name": "location", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false + }, + "parent_range": { + "name": "parent_range", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mountains_name_index": { + "name": "mountains_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mountains_location_villages_id_fk": { + "name": "mountains_location_villages_id_fk", + "tableFrom": "mountains", + "tableTo": "villages", + "columnsFrom": ["location"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "mountains_name_unique": { + "name": "mountains_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.provinces": { + "name": "provinces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "provinces_name_index": { + "name": "provinces_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "provinces_name_unique": { + "name": "provinces_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.riddles": { + "name": "riddles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "question": { + "name": "question", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true + }, + "answer": { + "name": "answer", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "categories": { + "name": "categories", + "type": "varchar(16)[]", + "primaryKey": false, + "notNull": false + }, + "hints": { + "name": "hints", + "type": "varchar(256)[]", + "primaryKey": false, + "notNull": false + }, + "complexity_level": { + "name": "complexity_level", + "type": "complexity_level", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "riddles_question_index": { + "name": "riddles_question_index", + "columns": [ + { + "expression": "question", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "riddles_answer_index": { + "name": "riddles_answer_index", + "columns": [ + { + "expression": "answer", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "riddles_categories_index": { + "name": "riddles_categories_index", + "columns": [ + { + "expression": "categories", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.sectors": { + "name": "sectors", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "district_id": { + "name": "district_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sectors_name_index": { + "name": "sectors_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sectors_district_id_districts_id_fk": { + "name": "sectors_district_id_districts_id_fk", + "tableFrom": "sectors", + "tableTo": "districts", + "columnsFrom": ["district_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "given_name": { + "name": "given_name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false + }, + "surname": { + "name": "surname", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "hashed_password": { + "name": "hashed_password", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'USER'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "users_email_index": { + "name": "users_email_index", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_name_index": { + "name": "users_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + } + } + }, + "public.villages": { + "name": "villages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "cell_id": { + "name": "cell_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "villages_name_index": { + "name": "villages_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "villages_cell_id_cells_id_fk": { + "name": "villages_cell_id_cells_id_fk", + "tableFrom": "villages", + "tableTo": "cells", + "columnsFrom": ["cell_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": { + "public.complexity_level": { + "name": "complexity_level", + "schema": "public", + "values": [ + "LEVEL_1", + "LEVEL_2", + "LEVEL_3", + "LEVEL_4", + "LEVEL_5", + "LEVEL_6", + "LEVEL_7" + ] + }, + "public.role": { + "name": "role", + "schema": "public", + "values": ["USER", "ADMIN"] + } + }, + "schemas": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/src/db/migrations/meta/0023_snapshot.json b/src/db/migrations/meta/0023_snapshot.json new file mode 100644 index 0000000..d8fa8b3 --- /dev/null +++ b/src/db/migrations/meta/0023_snapshot.json @@ -0,0 +1,904 @@ +{ + "id": "edf04ac2-674b-4c55-addb-9cd76239c306", + "prevId": "9996bcf9-18a9-4caa-9081-ed55005ca0b1", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.categories": { + "name": "categories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "categories_name_index": { + "name": "categories_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "categories_name_unique": { + "name": "categories_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.cells": { + "name": "cells", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "sector_id": { + "name": "sector_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cells_name_index": { + "name": "cells_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cells_sector_id_sectors_id_fk": { + "name": "cells_sector_id_sectors_id_fk", + "tableFrom": "cells", + "tableTo": "sectors", + "columnsFrom": ["sector_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.districts": { + "name": "districts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "province_id": { + "name": "province_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "districts_name_index": { + "name": "districts_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "districts_province_id_provinces_id_fk": { + "name": "districts_province_id_provinces_id_fk", + "tableFrom": "districts", + "tableTo": "provinces", + "columnsFrom": ["province_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "districts_name_unique": { + "name": "districts_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.mountains": { + "name": "mountains", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "elevation": { + "name": "elevation", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "native_name": { + "name": "native_name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false + }, + "hints": { + "name": "hints", + "type": "varchar(16)[]", + "primaryKey": false, + "notNull": false + }, + "location": { + "name": "location", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false + }, + "parent_range": { + "name": "parent_range", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mountains_name_index": { + "name": "mountains_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mountains_location_villages_id_fk": { + "name": "mountains_location_villages_id_fk", + "tableFrom": "mountains", + "tableTo": "villages", + "columnsFrom": ["location"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "mountains_name_unique": { + "name": "mountains_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.provinces": { + "name": "provinces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "provinces_name_index": { + "name": "provinces_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "provinces_name_unique": { + "name": "provinces_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.riddles": { + "name": "riddles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "question": { + "name": "question", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "answer": { + "name": "answer", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + }, + "categories": { + "name": "categories", + "type": "varchar(16)[]", + "primaryKey": false, + "notNull": false + }, + "hints": { + "name": "hints", + "type": "varchar(256)[]", + "primaryKey": false, + "notNull": false + }, + "complexity_level": { + "name": "complexity_level", + "type": "complexity_level", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "riddles_question_index": { + "name": "riddles_question_index", + "columns": [ + { + "expression": "question", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "riddles_answer_index": { + "name": "riddles_answer_index", + "columns": [ + { + "expression": "answer", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "riddles_categories_index": { + "name": "riddles_categories_index", + "columns": [ + { + "expression": "categories", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.sectors": { + "name": "sectors", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "district_id": { + "name": "district_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sectors_name_index": { + "name": "sectors_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sectors_district_id_districts_id_fk": { + "name": "sectors_district_id_districts_id_fk", + "tableFrom": "sectors", + "tableTo": "districts", + "columnsFrom": ["district_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "given_name": { + "name": "given_name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false + }, + "surname": { + "name": "surname", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "hashed_password": { + "name": "hashed_password", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'USER'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "users_email_index": { + "name": "users_email_index", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_name_index": { + "name": "users_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + } + } + }, + "public.villages": { + "name": "villages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "cell_id": { + "name": "cell_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "villages_name_index": { + "name": "villages_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "villages_cell_id_cells_id_fk": { + "name": "villages_cell_id_cells_id_fk", + "tableFrom": "villages", + "tableTo": "cells", + "columnsFrom": ["cell_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": { + "public.complexity_level": { + "name": "complexity_level", + "schema": "public", + "values": [ + "LEVEL_1", + "LEVEL_2", + "LEVEL_3", + "LEVEL_4", + "LEVEL_5", + "LEVEL_6", + "LEVEL_7" + ] + }, + "public.role": { + "name": "role", + "schema": "public", + "values": ["USER", "ADMIN"] + } + }, + "schemas": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/src/db/migrations/meta/0024_snapshot.json b/src/db/migrations/meta/0024_snapshot.json new file mode 100644 index 0000000..6d5cda6 --- /dev/null +++ b/src/db/migrations/meta/0024_snapshot.json @@ -0,0 +1,904 @@ +{ + "id": "025b01f0-3f33-453b-b7fa-eb726b156754", + "prevId": "edf04ac2-674b-4c55-addb-9cd76239c306", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.categories": { + "name": "categories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "categories_name_index": { + "name": "categories_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "categories_name_unique": { + "name": "categories_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.cells": { + "name": "cells", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "sector_id": { + "name": "sector_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cells_name_index": { + "name": "cells_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cells_sector_id_sectors_id_fk": { + "name": "cells_sector_id_sectors_id_fk", + "tableFrom": "cells", + "tableTo": "sectors", + "columnsFrom": ["sector_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.districts": { + "name": "districts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "province_id": { + "name": "province_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "districts_name_index": { + "name": "districts_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "districts_province_id_provinces_id_fk": { + "name": "districts_province_id_provinces_id_fk", + "tableFrom": "districts", + "tableTo": "provinces", + "columnsFrom": ["province_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "districts_name_unique": { + "name": "districts_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.mountains": { + "name": "mountains", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "elevation": { + "name": "elevation", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "native_name": { + "name": "native_name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false + }, + "hints": { + "name": "hints", + "type": "varchar(16)[]", + "primaryKey": false, + "notNull": false + }, + "location": { + "name": "location", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false + }, + "parent_range": { + "name": "parent_range", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mountains_name_index": { + "name": "mountains_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mountains_location_villages_id_fk": { + "name": "mountains_location_villages_id_fk", + "tableFrom": "mountains", + "tableTo": "villages", + "columnsFrom": ["location"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "mountains_name_unique": { + "name": "mountains_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.provinces": { + "name": "provinces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "provinces_name_index": { + "name": "provinces_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "provinces_name_unique": { + "name": "provinces_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.riddles": { + "name": "riddles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "question": { + "name": "question", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "answer": { + "name": "answer", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + }, + "categories": { + "name": "categories", + "type": "varchar(16)[]", + "primaryKey": false, + "notNull": false + }, + "hints": { + "name": "hints", + "type": "varchar(16)[]", + "primaryKey": false, + "notNull": false + }, + "complexity_level": { + "name": "complexity_level", + "type": "complexity_level", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "riddles_question_index": { + "name": "riddles_question_index", + "columns": [ + { + "expression": "question", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "riddles_answer_index": { + "name": "riddles_answer_index", + "columns": [ + { + "expression": "answer", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "riddles_categories_index": { + "name": "riddles_categories_index", + "columns": [ + { + "expression": "categories", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.sectors": { + "name": "sectors", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "district_id": { + "name": "district_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sectors_name_index": { + "name": "sectors_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sectors_district_id_districts_id_fk": { + "name": "sectors_district_id_districts_id_fk", + "tableFrom": "sectors", + "tableTo": "districts", + "columnsFrom": ["district_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "given_name": { + "name": "given_name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false + }, + "surname": { + "name": "surname", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "hashed_password": { + "name": "hashed_password", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'USER'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "users_email_index": { + "name": "users_email_index", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_name_index": { + "name": "users_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + } + } + }, + "public.villages": { + "name": "villages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "cell_id": { + "name": "cell_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "villages_name_index": { + "name": "villages_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "villages_cell_id_cells_id_fk": { + "name": "villages_cell_id_cells_id_fk", + "tableFrom": "villages", + "tableTo": "cells", + "columnsFrom": ["cell_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": { + "public.complexity_level": { + "name": "complexity_level", + "schema": "public", + "values": [ + "LEVEL_1", + "LEVEL_2", + "LEVEL_3", + "LEVEL_4", + "LEVEL_5", + "LEVEL_6", + "LEVEL_7" + ] + }, + "public.role": { + "name": "role", + "schema": "public", + "values": ["USER", "ADMIN"] + } + }, + "schemas": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/src/db/migrations/meta/0025_snapshot.json b/src/db/migrations/meta/0025_snapshot.json new file mode 100644 index 0000000..2636dd8 --- /dev/null +++ b/src/db/migrations/meta/0025_snapshot.json @@ -0,0 +1,904 @@ +{ + "id": "162f89d5-8461-4e78-a81d-1a7c1ff32343", + "prevId": "025b01f0-3f33-453b-b7fa-eb726b156754", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.categories": { + "name": "categories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "categories_name_index": { + "name": "categories_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "categories_name_unique": { + "name": "categories_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.cells": { + "name": "cells", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "sector_id": { + "name": "sector_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cells_name_index": { + "name": "cells_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cells_sector_id_sectors_id_fk": { + "name": "cells_sector_id_sectors_id_fk", + "tableFrom": "cells", + "tableTo": "sectors", + "columnsFrom": ["sector_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.districts": { + "name": "districts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "province_id": { + "name": "province_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "districts_name_index": { + "name": "districts_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "districts_province_id_provinces_id_fk": { + "name": "districts_province_id_provinces_id_fk", + "tableFrom": "districts", + "tableTo": "provinces", + "columnsFrom": ["province_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "districts_name_unique": { + "name": "districts_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.mountains": { + "name": "mountains", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "elevation": { + "name": "elevation", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "native_name": { + "name": "native_name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false + }, + "hints": { + "name": "hints", + "type": "varchar(16)[]", + "primaryKey": false, + "notNull": false + }, + "location": { + "name": "location", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false + }, + "parent_range": { + "name": "parent_range", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mountains_name_index": { + "name": "mountains_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mountains_location_villages_id_fk": { + "name": "mountains_location_villages_id_fk", + "tableFrom": "mountains", + "tableTo": "villages", + "columnsFrom": ["location"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "mountains_name_unique": { + "name": "mountains_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.provinces": { + "name": "provinces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "provinces_name_index": { + "name": "provinces_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "provinces_name_unique": { + "name": "provinces_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.riddles": { + "name": "riddles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "question": { + "name": "question", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true + }, + "answer": { + "name": "answer", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + }, + "categories": { + "name": "categories", + "type": "varchar(16)[]", + "primaryKey": false, + "notNull": false + }, + "hints": { + "name": "hints", + "type": "varchar(16)[]", + "primaryKey": false, + "notNull": false + }, + "complexity_level": { + "name": "complexity_level", + "type": "complexity_level", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "riddles_question_index": { + "name": "riddles_question_index", + "columns": [ + { + "expression": "question", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "riddles_answer_index": { + "name": "riddles_answer_index", + "columns": [ + { + "expression": "answer", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "riddles_categories_index": { + "name": "riddles_categories_index", + "columns": [ + { + "expression": "categories", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.sectors": { + "name": "sectors", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "district_id": { + "name": "district_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sectors_name_index": { + "name": "sectors_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sectors_district_id_districts_id_fk": { + "name": "sectors_district_id_districts_id_fk", + "tableFrom": "sectors", + "tableTo": "districts", + "columnsFrom": ["district_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "given_name": { + "name": "given_name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false + }, + "surname": { + "name": "surname", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "hashed_password": { + "name": "hashed_password", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'USER'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "users_email_index": { + "name": "users_email_index", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_name_index": { + "name": "users_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + } + } + }, + "public.villages": { + "name": "villages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "cell_id": { + "name": "cell_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "villages_name_index": { + "name": "villages_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "villages_cell_id_cells_id_fk": { + "name": "villages_cell_id_cells_id_fk", + "tableFrom": "villages", + "tableTo": "cells", + "columnsFrom": ["cell_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": { + "public.complexity_level": { + "name": "complexity_level", + "schema": "public", + "values": [ + "LEVEL_1", + "LEVEL_2", + "LEVEL_3", + "LEVEL_4", + "LEVEL_5", + "LEVEL_6", + "LEVEL_7" + ] + }, + "public.role": { + "name": "role", + "schema": "public", + "values": ["USER", "ADMIN"] + } + }, + "schemas": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/src/db/migrations/meta/0026_snapshot.json b/src/db/migrations/meta/0026_snapshot.json new file mode 100644 index 0000000..552f613 --- /dev/null +++ b/src/db/migrations/meta/0026_snapshot.json @@ -0,0 +1,904 @@ +{ + "id": "325d7656-4856-4493-ab29-cfb72e81efec", + "prevId": "162f89d5-8461-4e78-a81d-1a7c1ff32343", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.categories": { + "name": "categories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "categories_name_index": { + "name": "categories_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "categories_name_unique": { + "name": "categories_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.cells": { + "name": "cells", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "sector_id": { + "name": "sector_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "cells_name_index": { + "name": "cells_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "cells_sector_id_sectors_id_fk": { + "name": "cells_sector_id_sectors_id_fk", + "tableFrom": "cells", + "tableTo": "sectors", + "columnsFrom": ["sector_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.districts": { + "name": "districts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "province_id": { + "name": "province_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "districts_name_index": { + "name": "districts_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "districts_province_id_provinces_id_fk": { + "name": "districts_province_id_provinces_id_fk", + "tableFrom": "districts", + "tableTo": "provinces", + "columnsFrom": ["province_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "districts_name_unique": { + "name": "districts_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.mountains": { + "name": "mountains", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "jsonb", + "primaryKey": false, + "notNull": true + }, + "elevation": { + "name": "elevation", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": true + }, + "native_name": { + "name": "native_name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false + }, + "hints": { + "name": "hints", + "type": "varchar(16)[]", + "primaryKey": false, + "notNull": false + }, + "location": { + "name": "location", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false + }, + "parent_range": { + "name": "parent_range", + "type": "varchar(16)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "mountains_name_index": { + "name": "mountains_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "mountains_location_villages_id_fk": { + "name": "mountains_location_villages_id_fk", + "tableFrom": "mountains", + "tableTo": "villages", + "columnsFrom": ["location"], + "columnsTo": ["id"], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "mountains_name_unique": { + "name": "mountains_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.provinces": { + "name": "provinces", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "provinces_name_index": { + "name": "provinces_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "provinces_name_unique": { + "name": "provinces_name_unique", + "nullsNotDistinct": false, + "columns": ["name"] + } + } + }, + "public.riddles": { + "name": "riddles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "question": { + "name": "question", + "type": "varchar(128)", + "primaryKey": false, + "notNull": true + }, + "answer": { + "name": "answer", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "categories": { + "name": "categories", + "type": "varchar(16)[]", + "primaryKey": false, + "notNull": false + }, + "hints": { + "name": "hints", + "type": "varchar(16)[]", + "primaryKey": false, + "notNull": false + }, + "complexity_level": { + "name": "complexity_level", + "type": "complexity_level", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "riddles_question_index": { + "name": "riddles_question_index", + "columns": [ + { + "expression": "question", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "riddles_answer_index": { + "name": "riddles_answer_index", + "columns": [ + { + "expression": "answer", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "riddles_categories_index": { + "name": "riddles_categories_index", + "columns": [ + { + "expression": "categories", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.sectors": { + "name": "sectors", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "district_id": { + "name": "district_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "sectors_name_index": { + "name": "sectors_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "sectors_district_id_districts_id_fk": { + "name": "sectors_district_id_districts_id_fk", + "tableFrom": "sectors", + "tableTo": "districts", + "columnsFrom": ["district_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.sessions": { + "name": "sessions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar", + "primaryKey": true, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "sessions_user_id_users_id_fk": { + "name": "sessions_user_id_users_id_fk", + "tableFrom": "sessions", + "tableTo": "users", + "columnsFrom": ["user_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": true + }, + "given_name": { + "name": "given_name", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false + }, + "surname": { + "name": "surname", + "type": "varchar(64)", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "hashed_password": { + "name": "hashed_password", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "role": { + "name": "role", + "type": "role", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'USER'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "users_email_index": { + "name": "users_email_index", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_name_index": { + "name": "users_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": ["email"] + } + } + }, + "public.villages": { + "name": "villages", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "varchar(16)", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar(32)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "cell_id": { + "name": "cell_id", + "type": "varchar(16)", + "primaryKey": false, + "notNull": true + }, + "latitude": { + "name": "latitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "longitude": { + "name": "longitude", + "type": "double precision", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "villages_name_index": { + "name": "villages_name_index", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "villages_cell_id_cells_id_fk": { + "name": "villages_cell_id_cells_id_fk", + "tableFrom": "villages", + "tableTo": "cells", + "columnsFrom": ["cell_id"], + "columnsTo": ["id"], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": { + "public.complexity_level": { + "name": "complexity_level", + "schema": "public", + "values": [ + "LEVEL_1", + "LEVEL_2", + "LEVEL_3", + "LEVEL_4", + "LEVEL_5", + "LEVEL_6", + "LEVEL_7" + ] + }, + "public.role": { + "name": "role", + "schema": "public", + "values": ["USER", "ADMIN"] + } + }, + "schemas": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/src/db/migrations/meta/_journal.json b/src/db/migrations/meta/_journal.json index b55494e..ea4cc6a 100644 --- a/src/db/migrations/meta/_journal.json +++ b/src/db/migrations/meta/_journal.json @@ -155,6 +155,41 @@ "when": 1720396533590, "tag": "0021_rainy_living_mummy", "breakpoints": true + }, + { + "idx": 22, + "version": "7", + "when": 1720449563951, + "tag": "0022_legal_the_santerians", + "breakpoints": true + }, + { + "idx": 23, + "version": "7", + "when": 1720453616873, + "tag": "0023_equal_betty_brant", + "breakpoints": true + }, + { + "idx": 24, + "version": "7", + "when": 1720453686092, + "tag": "0024_black_white_queen", + "breakpoints": true + }, + { + "idx": 25, + "version": "7", + "when": 1720453849555, + "tag": "0025_wise_ironclad", + "breakpoints": true + }, + { + "idx": 26, + "version": "7", + "when": 1720454000438, + "tag": "0026_gorgeous_speed", + "breakpoints": true } ] } diff --git a/src/db/schemas/riddles.ts b/src/db/schemas/riddles.ts index 7db2f4d..0fb2184 100644 --- a/src/db/schemas/riddles.ts +++ b/src/db/schemas/riddles.ts @@ -30,10 +30,10 @@ export const riddles = pgTable( "riddles", { id: varchar("id", { length: 16 }).primaryKey().notNull(), - question: varchar("question", { length: 256 }).notNull(), - answer: varchar("answer", { length: 16 }).notNull(), - categories: varchar("categories", { length: 16 }).array().notNull(), - hints: varchar("hints", { length: 256 }).array().notNull(), + question: varchar("question", { length: 128 }).notNull(), + answer: varchar("answer", { length: 64 }).notNull(), + categories: varchar("categories", { length: 16 }).array(), + hints: varchar("hints", { length: 16 }).array(), complexity_level: complexity_level_enum("complexity_level").notNull(), created_at: timestamp("created_at").notNull().defaultNow(), updated_at: timestamp("updated_at").notNull().defaultNow(), diff --git a/src/scripts/populate.ts b/src/scripts/populate.ts new file mode 100644 index 0000000..c3c42f1 --- /dev/null +++ b/src/scripts/populate.ts @@ -0,0 +1,58 @@ +/** + * This is a template script for populating the database with data. + * However, you need to bring in your data, schema, and logic. + */ + +import { config } from "dotenv"; +import { eq } from "drizzle-orm"; +import { create_drizzle_client } from "~/db"; +import * as schema from "~/db/schemas"; +import { generate_new_id } from "~/utils/generate-id"; + +config({ path: ".dev.vars" }); + +async function main() { + console.time("script_duration"); + + if (!process.env.DATABASE_URL) { + throw new Error("DATABASE_URL is not set"); + } + + const database_url = process.env.DATABASE_URL; + + const db = create_drizzle_client(database_url); + // ________________________________ + // < Hello; write your logic here > + // -------------------------------- + // \ ^__^ + // \ (oo)\_______ + // (__)\ )\/\ + // ||----w | + // || || + const random_province_id = generate_new_id("province"); + const res = await db.query.provinces + .findFirst({ + where: eq(schema.provinces.id, random_province_id), + }) + .prepare("get_single_province") + .execute(); + if (!res) { + console.table("Nah! Nothing found 🤡"); + } else { + console.table(res); + } + // ______ + // < Bye > + // ------ + // \ ^__^ + // \ (oo)\_______ + // (__)\ )\/\ + // ||----w | + // || || + console.log("Script completed successfully 🎉🎉🎉"); + console.timeEnd("script_duration"); +} + +main().catch((error) => { + console.error(error); +});