diff --git "a/apps/www/Sjekkliste_oppl\303\246ring.pdf" "b/apps/www/Sjekkliste_oppl\303\246ring.pdf" new file mode 100644 index 00000000..8ff96362 Binary files /dev/null and "b/apps/www/Sjekkliste_oppl\303\246ring.pdf" differ diff --git a/apps/www/migrations/0017_lively_spacker_dave.sql b/apps/www/migrations/0017_lively_spacker_dave.sql deleted file mode 100644 index 6702e84f..00000000 --- a/apps/www/migrations/0017_lively_spacker_dave.sql +++ /dev/null @@ -1,8 +0,0 @@ -CREATE TABLE `contact_submission` ( - `id` text PRIMARY KEY NOT NULL, - `name` text NOT NULL, - `email` text NOT NULL, - `message` text NOT NULL, - `submitted_at` integer NOT NULL, - `ip_address` text -); diff --git a/apps/www/migrations/0017_magenta_white_tiger.sql b/apps/www/migrations/0017_magenta_white_tiger.sql new file mode 100644 index 00000000..590010c0 --- /dev/null +++ b/apps/www/migrations/0017_magenta_white_tiger.sql @@ -0,0 +1 @@ +ALTER TABLE `user` ADD `phone` text; \ No newline at end of file diff --git a/apps/www/migrations/0018_nostalgic_boomer.sql b/apps/www/migrations/0018_nostalgic_boomer.sql new file mode 100644 index 00000000..b4f586ae --- /dev/null +++ b/apps/www/migrations/0018_nostalgic_boomer.sql @@ -0,0 +1 @@ +ALTER TABLE `user` ADD `is_trained` integer DEFAULT false NOT NULL; \ No newline at end of file diff --git a/apps/www/migrations/0018_ordinary_may_parker.sql b/apps/www/migrations/0018_ordinary_may_parker.sql deleted file mode 100644 index 04742006..00000000 --- a/apps/www/migrations/0018_ordinary_may_parker.sql +++ /dev/null @@ -1,39 +0,0 @@ -CREATE TABLE `producers` ( - `id` text PRIMARY KEY NOT NULL, - `name` text NOT NULL, - `created_at` text NOT NULL, - `updated_at` text NOT NULL -); ---> statement-breakpoint -CREATE TABLE `product_types` ( - `id` text PRIMARY KEY NOT NULL, - `title` text NOT NULL, - `created_at` text NOT NULL, - `updated_at` text NOT NULL -); ---> statement-breakpoint -CREATE TABLE `products` ( - `id` text PRIMARY KEY NOT NULL, - `sku` text, - `name` text NOT NULL, - `description` text, - `is_sold_out` integer DEFAULT false NOT NULL, - `ordinary_price` integer NOT NULL, - `student_price` integer NOT NULL, - `internal_price` integer NOT NULL, - `credits` integer, - `volume` real, - `alcohol_content` real, - `variants` text, - `producer_id` text, - `created_at` text NOT NULL, - `updated_at` text NOT NULL, - FOREIGN KEY (`producer_id`) REFERENCES `producers`(`id`) ON UPDATE no action ON DELETE no action -); ---> statement-breakpoint -CREATE TABLE `product_product_types` ( - `product_id` text NOT NULL, - `product_type_id` text NOT NULL, - FOREIGN KEY (`product_id`) REFERENCES `products`(`id`) ON UPDATE no action ON DELETE cascade, - FOREIGN KEY (`product_type_id`) REFERENCES `product_types`(`id`) ON UPDATE no action ON DELETE cascade -); diff --git a/apps/www/migrations/0019_charming_magik.sql b/apps/www/migrations/0019_charming_magik.sql deleted file mode 100644 index fe7caf30..00000000 --- a/apps/www/migrations/0019_charming_magik.sql +++ /dev/null @@ -1,13 +0,0 @@ -CREATE TABLE `images` ( - `id` text PRIMARY KEY NOT NULL, - `filename` text NOT NULL, - `original_name` text NOT NULL, - `mime_type` text NOT NULL, - `size` integer NOT NULL, - `type` text NOT NULL, - `created_at` text NOT NULL, - `updated_at` text NOT NULL -); ---> statement-breakpoint -ALTER TABLE `producers` ADD `image_id` text;--> statement-breakpoint -ALTER TABLE `products` ADD `image_id` text; \ No newline at end of file diff --git a/apps/www/migrations/0020_silent_infant_terrible.sql b/apps/www/migrations/0020_silent_infant_terrible.sql deleted file mode 100644 index 3a9cb562..00000000 --- a/apps/www/migrations/0020_silent_infant_terrible.sql +++ /dev/null @@ -1,2 +0,0 @@ -ALTER TABLE `images` DROP COLUMN `original_name`;--> statement-breakpoint -ALTER TABLE `images` DROP COLUMN `mime_type`; \ No newline at end of file diff --git a/apps/www/migrations/0021_broken_professor_monster.sql b/apps/www/migrations/0021_broken_professor_monster.sql deleted file mode 100644 index 94cda257..00000000 --- a/apps/www/migrations/0021_broken_professor_monster.sql +++ /dev/null @@ -1,14 +0,0 @@ -PRAGMA foreign_keys=OFF;--> statement-breakpoint -CREATE TABLE `__new_images` ( - `id` text PRIMARY KEY NOT NULL, - `filename` text NOT NULL, - `size` integer NOT NULL, - `type` text NOT NULL, - `created_at` integer NOT NULL, - `updated_at` integer NOT NULL -); ---> statement-breakpoint -INSERT INTO `__new_images`("id", "filename", "size", "type", "created_at", "updated_at") SELECT "id", "filename", "size", "type", "created_at", "updated_at" FROM `images`;--> statement-breakpoint -DROP TABLE `images`;--> statement-breakpoint -ALTER TABLE `__new_images` RENAME TO `images`;--> statement-breakpoint -PRAGMA foreign_keys=ON; \ No newline at end of file diff --git a/apps/www/migrations/0026_puzzling_shadowcat.sql b/apps/www/migrations/0026_puzzling_shadowcat.sql new file mode 100644 index 00000000..1463ceb4 --- /dev/null +++ b/apps/www/migrations/0026_puzzling_shadowcat.sql @@ -0,0 +1,10 @@ +CREATE TABLE `referral` ( + `id` text PRIMARY KEY NOT NULL, + `referred_by` text NOT NULL, + `referred` text NOT NULL, + `status` text DEFAULT 'pending' NOT NULL, + `created_at` integer NOT NULL, + `completed_at` integer, + FOREIGN KEY (`referred_by`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action, + FOREIGN KEY (`referred`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE no action +); diff --git a/apps/www/migrations/0027_nice_bushwacker.sql b/apps/www/migrations/0027_nice_bushwacker.sql new file mode 100644 index 00000000..12148c6e --- /dev/null +++ b/apps/www/migrations/0027_nice_bushwacker.sql @@ -0,0 +1,7 @@ +CREATE TABLE `producers` ( + `id` text PRIMARY KEY NOT NULL, + `name` text NOT NULL, + `image_id` text, + `created_at` text NOT NULL, + `updated_at` text NOT NULL +); diff --git a/apps/www/migrations/0028_youthful_absorbing_man.sql b/apps/www/migrations/0028_youthful_absorbing_man.sql new file mode 100644 index 00000000..78e82014 --- /dev/null +++ b/apps/www/migrations/0028_youthful_absorbing_man.sql @@ -0,0 +1 @@ +ALTER TABLE `user` ADD `training_completed` integer DEFAULT false NOT NULL; \ No newline at end of file diff --git a/apps/www/migrations/0029_rename_training_column.sql b/apps/www/migrations/0029_rename_training_column.sql new file mode 100644 index 00000000..a994fd9a --- /dev/null +++ b/apps/www/migrations/0029_rename_training_column.sql @@ -0,0 +1 @@ +ALTER TABLE `user` DROP COLUMN `training_completed`; \ No newline at end of file diff --git a/apps/www/migrations/meta/0023_snapshot.json b/apps/www/migrations/meta/0023_snapshot.json new file mode 100644 index 00000000..2925ffd8 --- /dev/null +++ b/apps/www/migrations/meta/0023_snapshot.json @@ -0,0 +1,1094 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "1c6b740e-385b-42e8-8966-0bcefd2e40b3", + "prevId": "8127fb43-ed96-43ae-99a7-c2210af270b1", + "tables": { + "claimed_credits": { + "name": "claimed_credits", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "product_id": { + "name": "product_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credit_cost": { + "name": "credit_cost", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "claimed_credits_user_id_user_id_fk": { + "name": "claimed_credits_user_id_user_id_fk", + "tableFrom": "claimed_credits", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "contact_submission": { + "name": "contact_submission", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "submitted_at": { + "name": "submitted_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "event": { + "name": "event", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "date": { + "name": "date", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "group": { + "name": "group", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "invitation": { + "name": "invitation", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "invitation_email_idx": { + "name": "invitation_email_idx", + "columns": [ + "email" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "notification": { + "name": "notification", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "archived_at": { + "name": "archived_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "idx_notifications_user_id": { + "name": "idx_notifications_user_id", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "idx_notifications_archived_at": { + "name": "idx_notifications_archived_at", + "columns": [ + "archived_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "notification_user_id_user_id_fk": { + "name": "notification_user_id_user_id_fk", + "tableFrom": "notification", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "session": { + "name": "session", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "shift": { + "name": "shift", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "event_id": { + "name": "event_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "start_at": { + "name": "start_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "end_at": { + "name": "end_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "shift_event_id_event_id_fk": { + "name": "shift_event_id_event_id_fk", + "tableFrom": "shift", + "tableTo": "event", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user_shift": { + "name": "user_shift", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "shift_id": { + "name": "shift_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_beer_claimed": { + "name": "is_beer_claimed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'accepted'" + } + }, + "indexes": {}, + "foreignKeys": { + "user_shift_user_id_user_id_fk": { + "name": "user_shift_user_id_user_id_fk", + "tableFrom": "user_shift", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_shift_shift_id_shift_id_fk": { + "name": "user_shift_shift_id_shift_id_fk", + "tableFrom": "user_shift", + "tableTo": "shift", + "columnsFrom": [ + "shift_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users_groups": { + "name": "users_groups", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "users_groups_user_id_user_id_fk": { + "name": "users_groups_user_id_user_id_fk", + "tableFrom": "users_groups", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "users_groups_group_id_group_id_fk": { + "name": "users_groups_group_id_group_id_fk", + "tableFrom": "users_groups", + "tableTo": "group", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "feide_id": { + "name": "feide_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'normal'" + }, + "additional_beers": { + "name": "additional_beers", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "alt_email": { + "name": "alt_email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_deleted": { + "name": "is_deleted", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + } + }, + "indexes": { + "email_idx": { + "name": "email_idx", + "columns": [ + "email" + ], + "isUnique": true + }, + "feide_id_idx": { + "name": "feide_id_idx", + "columns": [ + "feide_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "producers": { + "name": "producers", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "image_id": { + "name": "image_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_types": { + "name": "product_types", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "products": { + "name": "products", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "sku": { + "name": "sku", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_sold_out": { + "name": "is_sold_out", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "ordinary_price": { + "name": "ordinary_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "student_price": { + "name": "student_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "internal_price": { + "name": "internal_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credits": { + "name": "credits", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "volume": { + "name": "volume", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "alcohol_content": { + "name": "alcohol_content", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "variants": { + "name": "variants", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_id": { + "name": "image_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "producer_id": { + "name": "producer_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "products_producer_id_producers_id_fk": { + "name": "products_producer_id_producers_id_fk", + "tableFrom": "products", + "tableTo": "producers", + "columnsFrom": [ + "producer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_product_types": { + "name": "product_product_types", + "columns": { + "product_id": { + "name": "product_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "product_type_id": { + "name": "product_type_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_product_types_product_id_products_id_fk": { + "name": "product_product_types_product_id_products_id_fk", + "tableFrom": "product_product_types", + "tableTo": "products", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "product_product_types_product_type_id_product_types_id_fk": { + "name": "product_product_types_product_type_id_product_types_id_fk", + "tableFrom": "product_product_types", + "tableTo": "product_types", + "columnsFrom": [ + "product_type_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "images": { + "name": "images", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "referral": { + "name": "referral", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "referred_by": { + "name": "referred_by", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "referred": { + "name": "referred", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "referral_referred_by_user_id_fk": { + "name": "referral_referred_by_user_id_fk", + "tableFrom": "referral", + "tableTo": "user", + "columnsFrom": [ + "referred_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "referral_referred_user_id_fk": { + "name": "referral_referred_user_id_fk", + "tableFrom": "referral", + "tableTo": "user", + "columnsFrom": [ + "referred" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "pending_application": { + "name": "pending_application", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "feide_id": { + "name": "feide_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "pending_application_email_idx": { + "name": "pending_application_email_idx", + "columns": [ + "email" + ], + "isUnique": false + }, + "pending_application_feide_id_idx": { + "name": "pending_application_feide_id_idx", + "columns": [ + "feide_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/apps/www/migrations/meta/0018_snapshot.json b/apps/www/migrations/meta/0024_snapshot.json similarity index 86% rename from apps/www/migrations/meta/0018_snapshot.json rename to apps/www/migrations/meta/0024_snapshot.json index a2d8e855..c8104156 100644 --- a/apps/www/migrations/meta/0018_snapshot.json +++ b/apps/www/migrations/meta/0024_snapshot.json @@ -1,8 +1,8 @@ { "version": "6", "dialect": "sqlite", - "id": "f41e8208-d356-40b8-a525-dc476ce21e84", - "prevId": "fb5fad95-c88c-47ff-840b-cc8983b0f888", + "id": "3108c400-70f1-4f7d-bf30-baac4f754b24", + "prevId": "1c6b740e-385b-42e8-8966-0bcefd2e40b3", "tables": { "claimed_credits": { "name": "claimed_credits", @@ -580,6 +580,13 @@ "notNull": false, "autoincrement": false }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, "is_deleted": { "name": "is_deleted", "type": "integer", @@ -627,6 +634,13 @@ "notNull": true, "autoincrement": false }, + "image_id": { + "name": "image_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, "created_at": { "name": "created_at", "type": "text", @@ -774,6 +788,13 @@ "notNull": false, "autoincrement": false }, + "image_id": { + "name": "image_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, "producer_id": { "name": "producer_id", "type": "text", @@ -866,6 +887,118 @@ "compositePrimaryKeys": {}, "uniqueConstraints": {}, "checkConstraints": {} + }, + "images": { + "name": "images", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "pending_application": { + "name": "pending_application", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "feide_id": { + "name": "feide_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "pending_application_email_idx": { + "name": "pending_application_email_idx", + "columns": [ + "email" + ], + "isUnique": false + }, + "pending_application_feide_id_idx": { + "name": "pending_application_feide_id_idx", + "columns": [ + "feide_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} } }, "views": {}, diff --git a/apps/www/migrations/meta/0025_snapshot.json b/apps/www/migrations/meta/0025_snapshot.json new file mode 100644 index 00000000..dcc42e03 --- /dev/null +++ b/apps/www/migrations/meta/0025_snapshot.json @@ -0,0 +1,1094 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "281b23f3-fabb-4e68-924a-6380b33653c1", + "prevId": "3108c400-70f1-4f7d-bf30-baac4f754b24", + "tables": { + "claimed_credits": { + "name": "claimed_credits", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "product_id": { + "name": "product_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credit_cost": { + "name": "credit_cost", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "claimed_credits_user_id_user_id_fk": { + "name": "claimed_credits_user_id_user_id_fk", + "tableFrom": "claimed_credits", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "contact_submission": { + "name": "contact_submission", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "submitted_at": { + "name": "submitted_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "event": { + "name": "event", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "date": { + "name": "date", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "group": { + "name": "group", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "invitation": { + "name": "invitation", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "invitation_email_idx": { + "name": "invitation_email_idx", + "columns": [ + "email" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "notification": { + "name": "notification", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "archived_at": { + "name": "archived_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "idx_notifications_user_id": { + "name": "idx_notifications_user_id", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "idx_notifications_archived_at": { + "name": "idx_notifications_archived_at", + "columns": [ + "archived_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "notification_user_id_user_id_fk": { + "name": "notification_user_id_user_id_fk", + "tableFrom": "notification", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "session": { + "name": "session", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "shift": { + "name": "shift", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "event_id": { + "name": "event_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "start_at": { + "name": "start_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "end_at": { + "name": "end_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "shift_event_id_event_id_fk": { + "name": "shift_event_id_event_id_fk", + "tableFrom": "shift", + "tableTo": "event", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user_shift": { + "name": "user_shift", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "shift_id": { + "name": "shift_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_beer_claimed": { + "name": "is_beer_claimed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'accepted'" + } + }, + "indexes": {}, + "foreignKeys": { + "user_shift_user_id_user_id_fk": { + "name": "user_shift_user_id_user_id_fk", + "tableFrom": "user_shift", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_shift_shift_id_shift_id_fk": { + "name": "user_shift_shift_id_shift_id_fk", + "tableFrom": "user_shift", + "tableTo": "shift", + "columnsFrom": [ + "shift_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users_groups": { + "name": "users_groups", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "users_groups_user_id_user_id_fk": { + "name": "users_groups_user_id_user_id_fk", + "tableFrom": "users_groups", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "users_groups_group_id_group_id_fk": { + "name": "users_groups_group_id_group_id_fk", + "tableFrom": "users_groups", + "tableTo": "group", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "feide_id": { + "name": "feide_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'normal'" + }, + "additional_beers": { + "name": "additional_beers", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "alt_email": { + "name": "alt_email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_deleted": { + "name": "is_deleted", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + } + }, + "indexes": { + "email_idx": { + "name": "email_idx", + "columns": [ + "email" + ], + "isUnique": true + }, + "feide_id_idx": { + "name": "feide_id_idx", + "columns": [ + "feide_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "producers": { + "name": "producers", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "image_id": { + "name": "image_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_types": { + "name": "product_types", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "products": { + "name": "products", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "sku": { + "name": "sku", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_sold_out": { + "name": "is_sold_out", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "ordinary_price": { + "name": "ordinary_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "student_price": { + "name": "student_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "internal_price": { + "name": "internal_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credits": { + "name": "credits", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "volume": { + "name": "volume", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "alcohol_content": { + "name": "alcohol_content", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "variants": { + "name": "variants", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_id": { + "name": "image_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "producer_id": { + "name": "producer_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "products_producer_id_producers_id_fk": { + "name": "products_producer_id_producers_id_fk", + "tableFrom": "products", + "tableTo": "producers", + "columnsFrom": [ + "producer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_product_types": { + "name": "product_product_types", + "columns": { + "product_id": { + "name": "product_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "product_type_id": { + "name": "product_type_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_product_types_product_id_products_id_fk": { + "name": "product_product_types_product_id_products_id_fk", + "tableFrom": "product_product_types", + "tableTo": "products", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "product_product_types_product_type_id_product_types_id_fk": { + "name": "product_product_types_product_type_id_product_types_id_fk", + "tableFrom": "product_product_types", + "tableTo": "product_types", + "columnsFrom": [ + "product_type_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "images": { + "name": "images", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "referral": { + "name": "referral", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "referred_by": { + "name": "referred_by", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "referred": { + "name": "referred", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "referral_referred_by_user_id_fk": { + "name": "referral_referred_by_user_id_fk", + "tableFrom": "referral", + "tableTo": "user", + "columnsFrom": [ + "referred_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "referral_referred_user_id_fk": { + "name": "referral_referred_user_id_fk", + "tableFrom": "referral", + "tableTo": "user", + "columnsFrom": [ + "referred" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "pending_application": { + "name": "pending_application", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "feide_id": { + "name": "feide_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "pending_application_email_idx": { + "name": "pending_application_email_idx", + "columns": [ + "email" + ], + "isUnique": false + }, + "pending_application_feide_id_idx": { + "name": "pending_application_feide_id_idx", + "columns": [ + "feide_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/apps/www/migrations/meta/0017_snapshot.json b/apps/www/migrations/meta/0026_snapshot.json similarity index 60% rename from apps/www/migrations/meta/0017_snapshot.json rename to apps/www/migrations/meta/0026_snapshot.json index 47c968bb..11ca5b7f 100644 --- a/apps/www/migrations/meta/0017_snapshot.json +++ b/apps/www/migrations/meta/0026_snapshot.json @@ -1,8 +1,8 @@ { "version": "6", "dialect": "sqlite", - "id": "fb5fad95-c88c-47ff-840b-cc8983b0f888", - "prevId": "40b4d375-0ca1-4f0d-9199-ec8759e79555", + "id": "99db6b88-480c-4980-b18a-0118f7bf7447", + "prevId": "281b23f3-fabb-4e68-924a-6380b33653c1", "tables": { "claimed_credits": { "name": "claimed_credits", @@ -580,6 +580,13 @@ "notNull": false, "autoincrement": false }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, "is_deleted": { "name": "is_deleted", "type": "integer", @@ -609,6 +616,389 @@ "compositePrimaryKeys": {}, "uniqueConstraints": {}, "checkConstraints": {} + }, + "producers": { + "name": "producers", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "image_id": { + "name": "image_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_types": { + "name": "product_types", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "products": { + "name": "products", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "sku": { + "name": "sku", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_sold_out": { + "name": "is_sold_out", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "ordinary_price": { + "name": "ordinary_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "student_price": { + "name": "student_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "internal_price": { + "name": "internal_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credits": { + "name": "credits", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "volume": { + "name": "volume", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "alcohol_content": { + "name": "alcohol_content", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "variants": { + "name": "variants", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_id": { + "name": "image_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "producer_id": { + "name": "producer_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "products_producer_id_producers_id_fk": { + "name": "products_producer_id_producers_id_fk", + "tableFrom": "products", + "tableTo": "producers", + "columnsFrom": [ + "producer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_product_types": { + "name": "product_product_types", + "columns": { + "product_id": { + "name": "product_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "product_type_id": { + "name": "product_type_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_product_types_product_id_products_id_fk": { + "name": "product_product_types_product_id_products_id_fk", + "tableFrom": "product_product_types", + "tableTo": "products", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "product_product_types_product_type_id_product_types_id_fk": { + "name": "product_product_types_product_type_id_product_types_id_fk", + "tableFrom": "product_product_types", + "tableTo": "product_types", + "columnsFrom": [ + "product_type_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "images": { + "name": "images", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "pending_application": { + "name": "pending_application", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "feide_id": { + "name": "feide_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "pending_application_email_idx": { + "name": "pending_application_email_idx", + "columns": [ + "email" + ], + "isUnique": false + }, + "pending_application_feide_id_idx": { + "name": "pending_application_feide_id_idx", + "columns": [ + "feide_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} } }, "views": {}, diff --git a/apps/www/migrations/meta/0016_snapshot.json b/apps/www/migrations/meta/0027_snapshot.json similarity index 53% rename from apps/www/migrations/meta/0016_snapshot.json rename to apps/www/migrations/meta/0027_snapshot.json index db86e5b2..1be08dd6 100644 --- a/apps/www/migrations/meta/0016_snapshot.json +++ b/apps/www/migrations/meta/0027_snapshot.json @@ -1,8 +1,8 @@ { "version": "6", "dialect": "sqlite", - "id": "40b4d375-0ca1-4f0d-9199-ec8759e79555", - "prevId": "926108a5-287d-4506-b541-734057782393", + "id": "a81b6267-ff23-4cb8-8f25-433420ef15f0", + "prevId": "22f7a61f-4ec4-4431-ba47-c8c6f0c9b2f9", "tables": { "claimed_credits": { "name": "claimed_credits", @@ -63,6 +63,58 @@ "uniqueConstraints": {}, "checkConstraints": {} }, + "contact_submission": { + "name": "contact_submission", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "submitted_at": { + "name": "submitted_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, "event": { "name": "event", "columns": { @@ -528,6 +580,13 @@ "notNull": false, "autoincrement": false }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, "is_deleted": { "name": "is_deleted", "type": "integer", @@ -557,6 +616,424 @@ "compositePrimaryKeys": {}, "uniqueConstraints": {}, "checkConstraints": {} + }, + "product_types": { + "name": "product_types", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "products": { + "name": "products", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "sku": { + "name": "sku", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_sold_out": { + "name": "is_sold_out", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "ordinary_price": { + "name": "ordinary_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "student_price": { + "name": "student_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "internal_price": { + "name": "internal_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credits": { + "name": "credits", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "volume": { + "name": "volume", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "alcohol_content": { + "name": "alcohol_content", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "variants": { + "name": "variants", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_id": { + "name": "image_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "producer_id": { + "name": "producer_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "products_producer_id_producers_id_fk": { + "name": "products_producer_id_producers_id_fk", + "tableFrom": "products", + "tableTo": "producers", + "columnsFrom": [ + "producer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_product_types": { + "name": "product_product_types", + "columns": { + "product_id": { + "name": "product_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "product_type_id": { + "name": "product_type_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_product_types_product_id_products_id_fk": { + "name": "product_product_types_product_id_products_id_fk", + "tableFrom": "product_product_types", + "tableTo": "products", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "product_product_types_product_type_id_product_types_id_fk": { + "name": "product_product_types_product_type_id_product_types_id_fk", + "tableFrom": "product_product_types", + "tableTo": "product_types", + "columnsFrom": [ + "product_type_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "images": { + "name": "images", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "referral": { + "name": "referral", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "referred_by": { + "name": "referred_by", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "referred": { + "name": "referred", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "referral_referred_by_user_id_fk": { + "name": "referral_referred_by_user_id_fk", + "tableFrom": "referral", + "tableTo": "user", + "columnsFrom": [ + "referred_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "referral_referred_user_id_fk": { + "name": "referral_referred_user_id_fk", + "tableFrom": "referral", + "tableTo": "user", + "columnsFrom": [ + "referred" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "pending_application": { + "name": "pending_application", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "feide_id": { + "name": "feide_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "pending_application_email_idx": { + "name": "pending_application_email_idx", + "columns": [ + "email" + ], + "isUnique": false + }, + "pending_application_feide_id_idx": { + "name": "pending_application_feide_id_idx", + "columns": [ + "feide_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} } }, "views": {}, diff --git a/apps/www/migrations/meta/0028_snapshot.json b/apps/www/migrations/meta/0028_snapshot.json new file mode 100644 index 00000000..f710b662 --- /dev/null +++ b/apps/www/migrations/meta/0028_snapshot.json @@ -0,0 +1,1102 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "a99769e3-5213-40b1-b9c0-137e93abc053", + "prevId": "cdd8588d-9181-46ab-b4c1-3145f177c4ab", + "tables": { + "claimed_credits": { + "name": "claimed_credits", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "product_id": { + "name": "product_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credit_cost": { + "name": "credit_cost", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "claimed_credits_user_id_user_id_fk": { + "name": "claimed_credits_user_id_user_id_fk", + "tableFrom": "claimed_credits", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "contact_submission": { + "name": "contact_submission", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "submitted_at": { + "name": "submitted_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "event": { + "name": "event", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "date": { + "name": "date", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "group": { + "name": "group", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "invitation": { + "name": "invitation", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "invitation_email_idx": { + "name": "invitation_email_idx", + "columns": [ + "email" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "notification": { + "name": "notification", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "archived_at": { + "name": "archived_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "idx_notifications_user_id": { + "name": "idx_notifications_user_id", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "idx_notifications_archived_at": { + "name": "idx_notifications_archived_at", + "columns": [ + "archived_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "notification_user_id_user_id_fk": { + "name": "notification_user_id_user_id_fk", + "tableFrom": "notification", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "session": { + "name": "session", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "shift": { + "name": "shift", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "event_id": { + "name": "event_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "start_at": { + "name": "start_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "end_at": { + "name": "end_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "shift_event_id_event_id_fk": { + "name": "shift_event_id_event_id_fk", + "tableFrom": "shift", + "tableTo": "event", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user_shift": { + "name": "user_shift", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "shift_id": { + "name": "shift_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_beer_claimed": { + "name": "is_beer_claimed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'accepted'" + } + }, + "indexes": {}, + "foreignKeys": { + "user_shift_user_id_user_id_fk": { + "name": "user_shift_user_id_user_id_fk", + "tableFrom": "user_shift", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_shift_shift_id_shift_id_fk": { + "name": "user_shift_shift_id_shift_id_fk", + "tableFrom": "user_shift", + "tableTo": "shift", + "columnsFrom": [ + "shift_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users_groups": { + "name": "users_groups", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "users_groups_user_id_user_id_fk": { + "name": "users_groups_user_id_user_id_fk", + "tableFrom": "users_groups", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "users_groups_group_id_group_id_fk": { + "name": "users_groups_group_id_group_id_fk", + "tableFrom": "users_groups", + "tableTo": "group", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "feide_id": { + "name": "feide_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'normal'" + }, + "additional_beers": { + "name": "additional_beers", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "alt_email": { + "name": "alt_email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "training_completed": { + "name": "training_completed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_deleted": { + "name": "is_deleted", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + } + }, + "indexes": { + "email_idx": { + "name": "email_idx", + "columns": [ + "email" + ], + "isUnique": true + }, + "feide_id_idx": { + "name": "feide_id_idx", + "columns": [ + "feide_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "producers": { + "name": "producers", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "image_id": { + "name": "image_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_types": { + "name": "product_types", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "products": { + "name": "products", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "sku": { + "name": "sku", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_sold_out": { + "name": "is_sold_out", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "ordinary_price": { + "name": "ordinary_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "student_price": { + "name": "student_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "internal_price": { + "name": "internal_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credits": { + "name": "credits", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "volume": { + "name": "volume", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "alcohol_content": { + "name": "alcohol_content", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "variants": { + "name": "variants", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_id": { + "name": "image_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "producer_id": { + "name": "producer_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "products_producer_id_producers_id_fk": { + "name": "products_producer_id_producers_id_fk", + "tableFrom": "products", + "tableTo": "producers", + "columnsFrom": [ + "producer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_product_types": { + "name": "product_product_types", + "columns": { + "product_id": { + "name": "product_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "product_type_id": { + "name": "product_type_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_product_types_product_id_products_id_fk": { + "name": "product_product_types_product_id_products_id_fk", + "tableFrom": "product_product_types", + "tableTo": "products", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "product_product_types_product_type_id_product_types_id_fk": { + "name": "product_product_types_product_type_id_product_types_id_fk", + "tableFrom": "product_product_types", + "tableTo": "product_types", + "columnsFrom": [ + "product_type_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "images": { + "name": "images", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "referral": { + "name": "referral", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "referred_by": { + "name": "referred_by", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "referred": { + "name": "referred", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "referral_referred_by_user_id_fk": { + "name": "referral_referred_by_user_id_fk", + "tableFrom": "referral", + "tableTo": "user", + "columnsFrom": [ + "referred_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "referral_referred_user_id_fk": { + "name": "referral_referred_user_id_fk", + "tableFrom": "referral", + "tableTo": "user", + "columnsFrom": [ + "referred" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "pending_application": { + "name": "pending_application", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "feide_id": { + "name": "feide_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "pending_application_email_idx": { + "name": "pending_application_email_idx", + "columns": [ + "email" + ], + "isUnique": false + }, + "pending_application_feide_id_idx": { + "name": "pending_application_feide_id_idx", + "columns": [ + "feide_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/apps/www/migrations/meta/0029_snapshot.json b/apps/www/migrations/meta/0029_snapshot.json new file mode 100644 index 00000000..a481607c --- /dev/null +++ b/apps/www/migrations/meta/0029_snapshot.json @@ -0,0 +1,1102 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "177a331a-0b1a-4201-a5e3-d93db7c1ed2f", + "prevId": "a99769e3-5213-40b1-b9c0-137e93abc053", + "tables": { + "claimed_credits": { + "name": "claimed_credits", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "product_id": { + "name": "product_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credit_cost": { + "name": "credit_cost", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "claimed_credits_user_id_user_id_fk": { + "name": "claimed_credits_user_id_user_id_fk", + "tableFrom": "claimed_credits", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "contact_submission": { + "name": "contact_submission", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "submitted_at": { + "name": "submitted_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "event": { + "name": "event", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "date": { + "name": "date", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "group": { + "name": "group", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "invitation": { + "name": "invitation", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "claimed_at": { + "name": "claimed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "invitation_email_idx": { + "name": "invitation_email_idx", + "columns": [ + "email" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "notification": { + "name": "notification", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "archived_at": { + "name": "archived_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "idx_notifications_user_id": { + "name": "idx_notifications_user_id", + "columns": [ + "user_id" + ], + "isUnique": false + }, + "idx_notifications_archived_at": { + "name": "idx_notifications_archived_at", + "columns": [ + "archived_at" + ], + "isUnique": false + } + }, + "foreignKeys": { + "notification_user_id_user_id_fk": { + "name": "notification_user_id_user_id_fk", + "tableFrom": "notification", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "session": { + "name": "session", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "expires_at": { + "name": "expires_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "shift": { + "name": "shift", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "event_id": { + "name": "event_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "start_at": { + "name": "start_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "end_at": { + "name": "end_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "shift_event_id_event_id_fk": { + "name": "shift_event_id_event_id_fk", + "tableFrom": "shift", + "tableTo": "event", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user_shift": { + "name": "user_shift", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "shift_id": { + "name": "shift_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_beer_claimed": { + "name": "is_beer_claimed", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'accepted'" + } + }, + "indexes": {}, + "foreignKeys": { + "user_shift_user_id_user_id_fk": { + "name": "user_shift_user_id_user_id_fk", + "tableFrom": "user_shift", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "user_shift_shift_id_shift_id_fk": { + "name": "user_shift_shift_id_shift_id_fk", + "tableFrom": "user_shift", + "tableTo": "shift", + "columnsFrom": [ + "shift_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "users_groups": { + "name": "users_groups", + "columns": { + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "group_id": { + "name": "group_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "users_groups_user_id_user_id_fk": { + "name": "users_groups_user_id_user_id_fk", + "tableFrom": "users_groups", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "users_groups_group_id_group_id_fk": { + "name": "users_groups_group_id_group_id_fk", + "tableFrom": "users_groups", + "tableTo": "group", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "user": { + "name": "user", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "feide_id": { + "name": "feide_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'normal'" + }, + "additional_beers": { + "name": "additional_beers", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": 0 + }, + "alt_email": { + "name": "alt_email", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "phone": { + "name": "phone", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_trained": { + "name": "is_trained", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "is_deleted": { + "name": "is_deleted", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + } + }, + "indexes": { + "email_idx": { + "name": "email_idx", + "columns": [ + "email" + ], + "isUnique": true + }, + "feide_id_idx": { + "name": "feide_id_idx", + "columns": [ + "feide_id" + ], + "isUnique": true + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "producers": { + "name": "producers", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "image_id": { + "name": "image_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_types": { + "name": "product_types", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "products": { + "name": "products", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "sku": { + "name": "sku", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "is_sold_out": { + "name": "is_sold_out", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": false + }, + "ordinary_price": { + "name": "ordinary_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "student_price": { + "name": "student_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "internal_price": { + "name": "internal_price", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "credits": { + "name": "credits", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "volume": { + "name": "volume", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "alcohol_content": { + "name": "alcohol_content", + "type": "real", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "variants": { + "name": "variants", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "image_id": { + "name": "image_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "producer_id": { + "name": "producer_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "products_producer_id_producers_id_fk": { + "name": "products_producer_id_producers_id_fk", + "tableFrom": "products", + "tableTo": "producers", + "columnsFrom": [ + "producer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "product_product_types": { + "name": "product_product_types", + "columns": { + "product_id": { + "name": "product_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "product_type_id": { + "name": "product_type_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "product_product_types_product_id_products_id_fk": { + "name": "product_product_types_product_id_products_id_fk", + "tableFrom": "product_product_types", + "tableTo": "products", + "columnsFrom": [ + "product_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "product_product_types_product_type_id_product_types_id_fk": { + "name": "product_product_types_product_type_id_product_types_id_fk", + "tableFrom": "product_product_types", + "tableTo": "product_types", + "columnsFrom": [ + "product_type_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "images": { + "name": "images", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "filename": { + "name": "filename", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "size": { + "name": "size", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "updated_at": { + "name": "updated_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "referral": { + "name": "referral", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "referred_by": { + "name": "referred_by", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "referred": { + "name": "referred", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false, + "default": "'pending'" + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "completed_at": { + "name": "completed_at", + "type": "integer", + "primaryKey": false, + "notNull": false, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": { + "referral_referred_by_user_id_fk": { + "name": "referral_referred_by_user_id_fk", + "tableFrom": "referral", + "tableTo": "user", + "columnsFrom": [ + "referred_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "referral_referred_user_id_fk": { + "name": "referral_referred_user_id_fk", + "tableFrom": "referral", + "tableTo": "user", + "columnsFrom": [ + "referred" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + }, + "pending_application": { + "name": "pending_application", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "feide_id": { + "name": "feide_id", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "created_at": { + "name": "created_at", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": { + "pending_application_email_idx": { + "name": "pending_application_email_idx", + "columns": [ + "email" + ], + "isUnique": false + }, + "pending_application_feide_id_idx": { + "name": "pending_application_feide_id_idx", + "columns": [ + "feide_id" + ], + "isUnique": false + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} \ No newline at end of file diff --git a/apps/www/migrations/meta/_journal.json b/apps/www/migrations/meta/_journal.json index 6cb18b1e..34deec19 100644 --- a/apps/www/migrations/meta/_journal.json +++ b/apps/www/migrations/meta/_journal.json @@ -162,6 +162,55 @@ "when": 1755703977027, "tag": "0022_gorgeous_callisto", "breakpoints": true + }, + { + "idx": 23, + "version": "6", + "when": 1755721411799, + "tag": "0023_nervous_blur", + "breakpoints": true + }, + { + "idx": 24, + "version": "6", + "when": 1755721612733, + "tag": "0024_gifted_night_thrasher", + "breakpoints": true + }, + { + "idx": 25, + "version": "6", + "when": 1755721642994, + "tag": "0025_noisy_young_avengers", + "breakpoints": true + }, + { + "idx": 26, + "version": "6", + "when": 1755721897743, + "tag": "0026_puzzling_shadowcat", + "breakpoints": true + }, + { + "idx": 27, + "version": "6", + "when": 1755722369023, + "tag": "0027_nice_bushwacker", + "breakpoints": true + }, + { + "idx": 28, + "version": "6", + "when": 1755773799970, + "tag": "0028_youthful_absorbing_man", + "breakpoints": true + }, + { + "idx": 29, + "version": "6", + "when": 1755774144261, + "tag": "0029_nosy_selene", + "breakpoints": true } ] } \ No newline at end of file diff --git a/apps/www/scripts/referrals.ts b/apps/www/scripts/referrals.ts new file mode 100644 index 00000000..cdd53c93 --- /dev/null +++ b/apps/www/scripts/referrals.ts @@ -0,0 +1,64 @@ +import { faker } from '@faker-js/faker'; +import { nanoid } from 'nanoid'; +import { referrals, users } from '../src/lib/db/schemas'; +import { setup } from './setup'; + +async function main() { + const { db } = await setup(); + + const allUsers = await db.select({ id: users.id }).from(users); + + if (allUsers.length < 2) { + console.log('Need at least 2 users to create referrals. Run users.ts first.'); + return; + } + + console.log(`Found ${allUsers.length} users to create referrals between.`); + + const numberOfReferrals = Math.min(25, Math.floor(allUsers.length / 2)); + + const fakeReferrals = Array.from({ length: numberOfReferrals }, () => { + // Pick two random different users + const shuffledUsers = faker.helpers.shuffle([...allUsers]); + const referrer = shuffledUsers[0]; + const referred = shuffledUsers[1]; + + const status = faker.helpers.weightedArrayElement([ + { weight: 3, value: 'completed' as const }, + { weight: 2, value: 'pending' as const } + ]); + + const createdAt = faker.date.recent({ days: 90 }); // Within last 90 days + const completedAt = + status === 'completed' ? faker.date.between({ from: createdAt, to: new Date() }) : null; + + return { + id: nanoid(), + referredBy: referrer.id, + referred: referred.id, + status, + createdAt, + completedAt + }; + }); + + // Insert referrals one by one to avoid parameter limits + for (const referral of fakeReferrals) { + try { + await db.insert(referrals).values(referral); + } catch (error) { + console.warn('Skipped duplicate referral:', error); + } + } + + console.log(`Added ${fakeReferrals.length} referrals with various statuses.`); +} + +main() + .then(() => { + process.exit(0); + }) + .catch((err) => { + console.error(err); + process.exit(1); + }); diff --git a/apps/www/src/app.d.ts b/apps/www/src/app.d.ts index ef36f791..8d7afdc5 100644 --- a/apps/www/src/app.d.ts +++ b/apps/www/src/app.d.ts @@ -37,6 +37,7 @@ declare global { productTypeService: import('$lib/services/product-type.service').ProductTypeService; productService: import('$lib/services/product.service').ProductService; imageService: import('$lib/services/image.service').ImageService; + referralService: import('$lib/services/referral.service').ReferralService; pendingApplicationService: import('$lib/services/pending-application.service').PendingApplicationService; } // interface PageData {} diff --git a/apps/www/src/hooks.server.ts b/apps/www/src/hooks.server.ts index 836d3aa4..f9b7b800 100644 --- a/apps/www/src/hooks.server.ts +++ b/apps/www/src/hooks.server.ts @@ -19,6 +19,7 @@ import { UserService } from '$lib/services/user.service'; import type { Handle } from '@sveltejs/kit'; import { Resend } from 'resend'; import { ImageService } from '$lib/services/image.service'; +import { ReferralService } from '$lib/services/referral.service'; import { PendingApplicationService } from '$lib/services/pending-application.service'; export const handle: Handle = async ({ event, resolve }) => { @@ -104,6 +105,9 @@ export const handle: Handle = async ({ event, resolve }) => { const imageService = new ImageService(R2_BUCKET, db); event.locals.imageService = imageService; + const referralService = new ReferralService(db); + event.locals.referralService = referralService; + const pendingApplicationService = new PendingApplicationService(db); event.locals.pendingApplicationService = pendingApplicationService; diff --git a/apps/www/src/lib/components/portal/EventTable.svelte b/apps/www/src/lib/components/portal/EventTable.svelte index 1833e665..45998951 100644 --- a/apps/www/src/lib/components/portal/EventTable.svelte +++ b/apps/www/src/lib/components/portal/EventTable.svelte @@ -123,7 +123,7 @@ -
+
{#if $user?.role === 'board'} + {#if isTrainingMode} + + {/if} +
+
+ + + {#if isTrainingMode} + + {/if} + +{/if} diff --git a/apps/www/src/lib/constants/training.ts b/apps/www/src/lib/constants/training.ts new file mode 100644 index 00000000..a8220799 --- /dev/null +++ b/apps/www/src/lib/constants/training.ts @@ -0,0 +1,160 @@ +export interface TrainingItem { + id: number; + title: string; + description: string; + completed: boolean; + category: string; +} + +export const TRAINING_CATEGORIES = { + BAR_USAGE: 'Bruk av bar', + LAWS_SAFETY: 'Lover og sikkerhet', + HYGIENE_CLEANING: 'Vask og hygiene' +} as const; + +export const DEFAULT_TRAINING_ITEMS: TrainingItem[] = [ + { + id: 1, + title: 'Bytte keg på en riktig måte', + description: 'Lært at kegs burde bli oppbevart kjølig og stående kaldt for å holde seg', + completed: false, + category: TRAINING_CATEGORIES.BAR_USAGE + }, + { + id: 2, + title: 'Tappe pils på en riktig måte', + description: 'Riktig tapping av øl', + completed: false, + category: TRAINING_CATEGORIES.BAR_USAGE + }, + { + id: 3, + title: 'Glassvasken', + description: 'Skru på/av glassvasken, tømme og skylle glass før maskinen', + completed: false, + category: TRAINING_CATEGORIES.BAR_USAGE + }, + { + id: 4, + title: 'Isbiter og isbitmaskin', + description: 'Bruke dedikert isbit "skje", sjekke at maskinen er på og lager isbiter', + completed: false, + category: TRAINING_CATEGORIES.BAR_USAGE + }, + { + id: 5, + title: 'Kassesystem', + description: + 'Åpne kassen, ta imot betaling (vanlig pris og internpris), slette/redigere priser, stenge kassen', + completed: false, + category: TRAINING_CATEGORIES.BAR_USAGE + }, + { + id: 6, + title: 'Påfyll av varer', + description: 'Fylle på varer kontinuerlig, spesielt mot slutten av vakten', + completed: false, + category: TRAINING_CATEGORIES.BAR_USAGE + }, + { + id: 7, + title: 'Temperatursjekk', + description: 'Sjekke temperatur på kjøleskap (skal bli skrevet ned)', + completed: false, + category: TRAINING_CATEGORIES.BAR_USAGE + }, + { + id: 8, + title: 'Ikke oversjenke', + description: 'Aldri oversjenke da dette er ulovlig', + completed: false, + category: TRAINING_CATEGORIES.LAWS_SAFETY + }, + { + id: 9, + title: 'Autoritet til å si nei', + description: 'Har autoritet til å si nei til å servere alkohol', + completed: false, + category: TRAINING_CATEGORIES.LAWS_SAFETY + }, + { + id: 10, + title: 'Skjenkeløyve og dokumenter', + description: 'Hvor skjenkeløyve og opplæringsskjema er i baren, i tilfelle kontroll', + completed: false, + category: TRAINING_CATEGORIES.LAWS_SAFETY + }, + { + id: 11, + title: 'Nødsituasjoner', + description: 'Vite hva å gjøre i nødsituasjon, for eksempel brann', + completed: false, + category: TRAINING_CATEGORIES.LAWS_SAFETY + }, + { + id: 12, + title: 'Fast skjenkeløyve', + description: 'Baren har fast skjenkeløyve som vi kan miste hvis vi får for mange prikker', + completed: false, + category: TRAINING_CATEGORIES.LAWS_SAFETY + }, + { + id: 13, + title: 'Alkoholreklame', + description: + 'Ikke lov til å reklamere for alkohol, ikke foreslå alkohol men spørre "Hva vil du ha?"', + completed: false, + category: TRAINING_CATEGORIES.LAWS_SAFETY + }, + { + id: 14, + title: 'Renhold i baren', + description: + 'Viktigheten av å holde det rent i baren og på lageret (før, under og etter servering)', + completed: false, + category: TRAINING_CATEGORIES.HYGIENE_CLEANING + }, + { + id: 15, + title: 'Personlig hygiene', + description: 'Viktigheten av å ha god personlig hygiene', + completed: false, + category: TRAINING_CATEGORIES.HYGIENE_CLEANING + }, + { + id: 16, + title: 'Håndvask', + description: 'Hvordan vaske hendene ordentlig', + completed: false, + category: TRAINING_CATEGORIES.HYGIENE_CLEANING + }, + { + id: 17, + title: 'Rengjøring av arbeidsflater', + description: 'Hvordan tørke over benk og vask av gulv', + completed: false, + category: TRAINING_CATEGORIES.HYGIENE_CLEANING + }, + { + id: 18, + title: 'Søppelhåndtering', + description: 'Hva å gjøre med papp og annet søppel, og koden til søppelstasjonen', + completed: false, + category: TRAINING_CATEGORIES.HYGIENE_CLEANING + }, + { + id: 19, + title: 'Vask etter kegbytte', + description: 'Bytter man keg, så vasker man hendene', + completed: false, + category: TRAINING_CATEGORIES.HYGIENE_CLEANING + }, + { + id: 20, + title: 'Rengjøring av barutstyr', + description: + 'Vask og rengjør barutstyr, f.eks. tappetårn, målebeger, shaker, isøse, barskje osv.', + completed: false, + category: TRAINING_CATEGORIES.HYGIENE_CLEANING + } +]; diff --git a/apps/www/src/lib/db/schemas/index.ts b/apps/www/src/lib/db/schemas/index.ts index f7dd49ef..3607c956 100644 --- a/apps/www/src/lib/db/schemas/index.ts +++ b/apps/www/src/lib/db/schemas/index.ts @@ -14,4 +14,5 @@ export * from './product-types'; export * from './products'; export * from './product-product-types'; export * from './images'; +export * from './referrals'; export * from './pending-applications'; diff --git a/apps/www/src/lib/db/schemas/referrals.ts b/apps/www/src/lib/db/schemas/referrals.ts new file mode 100644 index 00000000..04f9056c --- /dev/null +++ b/apps/www/src/lib/db/schemas/referrals.ts @@ -0,0 +1,36 @@ +import { sqliteTable, text, integer } from 'drizzle-orm/sqlite-core'; +import { users } from './users'; +import { relations, type InferSelectModel, type InferInsertModel } from 'drizzle-orm'; + +export const referrals = sqliteTable('referral', { + id: text('id').primaryKey(), + referredBy: text() + .notNull() + .references(() => users.id), + referred: text() + .notNull() + .references(() => users.id), + status: text({ enum: ['pending', 'completed', 'expired'] }) + .notNull() + .default('pending'), + createdAt: integer('created_at', { mode: 'timestamp' }) + .notNull() + .$defaultFn(() => new Date()), + completedAt: integer({ mode: 'timestamp' }) +}); + +export const referralsRelations = relations(referrals, ({ one }) => ({ + referrer: one(users, { + fields: [referrals.referredBy], + references: [users.id], + relationName: 'referrer' + }), + referred: one(users, { + fields: [referrals.referred], + references: [users.id], + relationName: 'referred' + }) +})); + +export type Referral = InferSelectModel; +export type ReferralInsert = InferInsertModel; diff --git a/apps/www/src/lib/db/schemas/users.ts b/apps/www/src/lib/db/schemas/users.ts index 46c834c4..64a91d78 100644 --- a/apps/www/src/lib/db/schemas/users.ts +++ b/apps/www/src/lib/db/schemas/users.ts @@ -4,6 +4,7 @@ import { sessions } from './sessions'; import { shifts } from './shifts'; import { usersGroups } from './users-groups'; import { notifications } from './notifications'; +import { referrals } from './referrals'; export const users = sqliteTable( 'user', @@ -17,6 +18,8 @@ export const users = sqliteTable( .default('normal'), additionalBeers: integer().default(0).notNull(), altEmail: text(), + phone: text(), + isTrained: integer({ mode: 'boolean' }).default(false).notNull(), isDeleted: integer({ mode: 'boolean' }).default(false).notNull() }, (t) => [uniqueIndex('email_idx').on(t.email), uniqueIndex('feide_id_idx').on(t.feideId)] @@ -26,7 +29,9 @@ export const usersRelations = relations(users, ({ many }) => ({ sessions: many(sessions), shifts: many(shifts), memberships: many(usersGroups), - notifications: many(notifications) + notifications: many(notifications), + referralsGiven: many(referrals, { relationName: 'referrer' }), + referralsReceived: many(referrals, { relationName: 'referred' }) })); export type User = InferSelectModel; diff --git a/apps/www/src/lib/services/referral.service.ts b/apps/www/src/lib/services/referral.service.ts new file mode 100644 index 00000000..e5bde82e --- /dev/null +++ b/apps/www/src/lib/services/referral.service.ts @@ -0,0 +1,128 @@ +import type { Database } from '$lib/db/drizzle'; +import { eq, and } from 'drizzle-orm'; +import { referrals, users, type ReferralInsert } from '$lib/db/schemas'; +import { nanoid } from 'nanoid'; + +export class ReferralService { + #db: Database; + + constructor(db: Database) { + this.#db = db; + } + + async createReferral(referrerId: string, referredId: string) { + const referral: ReferralInsert = { + id: nanoid(), + referredBy: referrerId, + referred: referredId, + status: 'pending' + }; + + return await this.#db + .insert(referrals) + .values(referral) + .returning() + .then((rows) => rows[0]); + } + + async completeReferral(referredUserId: string) { + return await this.#db + .update(referrals) + .set({ + status: 'completed', + completedAt: new Date() + }) + .where(and(eq(referrals.referred, referredUserId), eq(referrals.status, 'pending'))) + .returning() + .then((rows) => rows[0]); + } + + async getReferralsGivenByUser(userId: string) { + return await this.#db.query.users.findFirst({ + where: (row, { eq }) => eq(row.id, userId), + with: { + referralsGiven: { + with: { + referred: true + } + } + } + }); + } + + async getReferralsReceivedByUser(userId: string) { + return await this.#db.query.users.findFirst({ + where: (row, { eq }) => eq(row.id, userId), + with: { + referralsReceived: { + with: { + referrer: true + } + } + } + }); + } + + async canUserRefer(userId: string) { + const existingReferral = await this.#db + .select() + .from(referrals) + .where(eq(referrals.referred, userId)); + return existingReferral.length === 0; + } + + async findPendingReferralForUser(userId: string) { + return await this.#db.query.referrals.findFirst({ + where: (row, { eq, and }) => and(eq(row.referred, userId), eq(row.status, 'pending')) + }); + } + + async awardReferralCredit(referrerId: string) { + const stats = await this.getReferralStats(referrerId); + const completedReferrals = stats.completedReferrals; + + const earnedBeers = Math.floor(completedReferrals / 2); + + const previousCompletedReferrals = completedReferrals - 1; + const previousEarnedBeers = Math.floor(previousCompletedReferrals / 2); + + if (earnedBeers > previousEarnedBeers) { + const user = await this.#db.query.users.findFirst({ + where: (row, { eq }) => eq(row.id, referrerId) + }); + + if (!user) return null; + + const [updated] = await this.#db + .update(users) + .set({ + additionalBeers: (user.additionalBeers || 0) + 1 + }) + .where(eq(users.id, referrerId)) + .returning(); + + return updated; + } + + return null; + } + + async getReferralStats(userId: string) { + const given = await this.#db.query.users.findFirst({ + where: (row, { eq }) => eq(row.id, userId), + with: { + referralsGiven: true + } + }); + + const completedCount = + given?.referralsGiven.filter((r) => r.status === 'completed').length || 0; + const pendingCount = given?.referralsGiven.filter((r) => r.status === 'pending').length || 0; + + return { + totalReferrals: given?.referralsGiven.length || 0, + completedReferrals: completedCount, + pendingReferrals: pendingCount + }; + } +} diff --git a/apps/www/src/lib/services/user.service.ts b/apps/www/src/lib/services/user.service.ts index 6dbcb6e2..c6e99343 100644 --- a/apps/www/src/lib/services/user.service.ts +++ b/apps/www/src/lib/services/user.service.ts @@ -47,6 +47,24 @@ export class UserService { .then((rows) => rows[0]); } + async updatePhone(userId: string, phone: string) { + return await this.#db + .update(users) + .set({ phone }) + .where(eq(users.id, userId)) + .returning() + .then((rows) => rows[0]); + } + + async updateTrainingStatus(userId: string, isTrained: boolean) { + return await this.#db + .update(users) + .set({ isTrained }) + .where(eq(users.id, userId)) + .returning() + .then((rows) => rows[0]); + } + async findById(userId: string) { const user = await this.#db .select() diff --git a/apps/www/src/routes/portal/+page.server.ts b/apps/www/src/routes/portal/+page.server.ts index 8dadcbe9..7e732790 100644 --- a/apps/www/src/routes/portal/+page.server.ts +++ b/apps/www/src/routes/portal/+page.server.ts @@ -1,4 +1,4 @@ -import { redirect } from '@sveltejs/kit'; +import { redirect, fail, type Actions } from '@sveltejs/kit'; import type { PageServerLoad } from './$types'; export const load: PageServerLoad = async ({ locals }) => { @@ -6,15 +6,85 @@ export const load: PageServerLoad = async ({ locals }) => { throw redirect(307, '/login'); } - const [userShifts, unclaimedBeers, upcomingShifts] = await Promise.all([ - locals.shiftService.findCompletedShiftsByUserId(locals.user.id), - locals.beerService.getTotalAvailableBeers(locals.user.id), - locals.shiftService.findUpcomingShiftsByUserId(locals.user.id) - ]); + const [userShifts, unclaimedBeers, upcomingShifts, canUserRefer, users, referralStats] = + await Promise.all([ + locals.shiftService.findCompletedShiftsByUserId(locals.user.id), + locals.beerService.getTotalAvailableBeers(locals.user.id), + locals.shiftService.findUpcomingShiftsByUserId(locals.user.id), + locals.referralService.canUserRefer(locals.user.id), + locals.userService.findAll().then((users) => + users.map((user) => ({ + label: user.name, + value: user.id + })) + ), + locals.referralService.getReferralStats(locals.user.id) + ]); + + // Cheks if an referred user has had it first shift. + try { + const allUsers = await locals.userService.findAll(); + + for (const user of allUsers) { + const completedShifts = await locals.shiftService.findCompletedShiftsByUserId(user.id); + + if (completedShifts.length > 0) { + const referral = await locals.referralService.completeReferral(user.id); + if (referral) { + await locals.referralService.awardReferralCredit(referral.referredBy); + } + } + } + } catch (error) { + console.error('Referral check failed:', error); + } return { shiftsCompleted: userShifts.length, unclaimedBeers: unclaimedBeers, - upcomingShifts + upcomingShifts, + canRefer: canUserRefer, + users, + referralStats, + currentUserId: locals.user.id }; }; + +export const actions: Actions = { + refer: async ({ request, locals }) => { + if (!locals.user) { + throw redirect(307, '/login'); + } + + const formData = await request.formData(); + const referrerId = formData.get('referrerId')?.toString(); + + if (referrerId === locals.user.id) { + return fail(400, { error: 'Du kan ikke referrere deg selv' }); + } + + if (!referrerId) { + return fail(400, { error: 'No person found' }); + } + + const canRefer = await locals.referralService.canUserRefer(locals.user.id); + if (!canRefer) { + return fail(400, { error: 'Cannot refer' }); + } + + const existingReferral = await locals.referralService.findPendingReferralForUser( + locals.user.id + ); + if (existingReferral) { + return fail(400, { error: 'Du har skrevet inn den som referrete deg' }); + } + + try { + await locals.referralService.createReferral(referrerId, locals.user.id); + return { success: true }; + } catch (error) { + console.error('Referral creation failed:', error); + return fail(500, { error: 'Noe gikk galt' }); + } + } +}; diff --git a/apps/www/src/routes/portal/+page.svelte b/apps/www/src/routes/portal/+page.svelte index 7c9e8872..5fc88fa6 100644 --- a/apps/www/src/routes/portal/+page.svelte +++ b/apps/www/src/routes/portal/+page.svelte @@ -1,8 +1,12 @@ @@ -10,6 +14,40 @@
+ {#if data.canRefer} +
+
+
+
+

+ Skriv namnet på den som referte deg +

+
+
+ user.value !== data.currentUserId)} + inputProps={{ placeholder: "Søk etter navn...", class: "w-full" }} + /> +
+ +
+ +
+
+
+
+ {/if} +
Vakter ferdig: @@ -22,8 +60,29 @@
- Kommende vakter + Referral Stats +
+
+ Total: + {data.referralStats.totalReferrals} +
+
+ Fullført 1 vakt: + {data.referralStats.completedReferrals} +
+
+ Ventende: + {data.referralStats.pendingReferrals} +
+
+
+
+ Kommende vakter
    {#each data.upcomingShifts as shift (shift.shift.id)}
  • diff --git a/apps/www/src/routes/portal/admin/+page.server.ts b/apps/www/src/routes/portal/admin/+page.server.ts index f13bba4b..878a6447 100644 --- a/apps/www/src/routes/portal/admin/+page.server.ts +++ b/apps/www/src/routes/portal/admin/+page.server.ts @@ -15,7 +15,7 @@ export const load: PageServerLoad = async ({ locals }) => { }; export const actions: Actions = { - default: async ({ request, locals }) => { + updateRole: async ({ request, locals }) => { const formData = await request.formData(); const userId = formData.get('userId') as string; const role = formData.get('role'); diff --git a/apps/www/src/routes/portal/admin/+page.svelte b/apps/www/src/routes/portal/admin/+page.svelte index 93d3984b..136f6a1a 100644 --- a/apps/www/src/routes/portal/admin/+page.svelte +++ b/apps/www/src/routes/portal/admin/+page.svelte @@ -1,75 +1,224 @@ - Admin - User Management + Admin -{#if isModalOpen && selectedUser} - -{/if} +
    +
    + Admin side +
    + {filteredUsers.length} + {filteredUsers.length === 1 ? 'bruker' : 'brukere'} +
    +
    -
    - Styret -
      - {#each boardMembers as user (user.id)} -
    • - { - selectedUser = user; - isModalOpen = true; - }} +
      +
      +
      + -
    • - {/each} -
    -
    +
    +
    + +
    +
+
-
- Frivillige - - -
+ {#if filteredUsers.length === 0} +
+
+
👤
+
Ingen brukere funnet
+ {#if search} +
Prøv å endre søkekriteriene
+ {/if} +
+
+ {/if} + + + + diff --git a/apps/www/src/routes/portal/admin/cms/producers/+page.svelte b/apps/www/src/routes/portal/admin/cms/producers/+page.svelte index 3f8cc366..b7b9a042 100644 --- a/apps/www/src/routes/portal/admin/cms/producers/+page.svelte +++ b/apps/www/src/routes/portal/admin/cms/producers/+page.svelte @@ -22,7 +22,7 @@ -
+
{#if data.producers.length === 0}
@@ -31,8 +31,8 @@
{:else}
- - +
+ - + {#each data.producers as producer (producer.id)}
diff --git a/apps/www/src/routes/portal/admin/cms/product-types/+page.svelte b/apps/www/src/routes/portal/admin/cms/product-types/+page.svelte index f511f9d0..5643aeda 100644 --- a/apps/www/src/routes/portal/admin/cms/product-types/+page.svelte +++ b/apps/www/src/routes/portal/admin/cms/product-types/+page.svelte @@ -24,7 +24,7 @@ -
+
{#if data.productTypes.length === 0}
@@ -33,8 +33,8 @@
{:else}
- - +
+ - + {#each data.productTypes as productType (productType.id)}
diff --git a/apps/www/src/routes/portal/admin/cms/products/+page.svelte b/apps/www/src/routes/portal/admin/cms/products/+page.svelte index a08887ff..71c13b87 100644 --- a/apps/www/src/routes/portal/admin/cms/products/+page.svelte +++ b/apps/www/src/routes/portal/admin/cms/products/+page.svelte @@ -23,7 +23,7 @@ -
+
{#if data.products.length === 0}
@@ -32,8 +32,8 @@
{:else}
- - +
+ - + {#each data.products as product (product.id)}
diff --git a/apps/www/src/routes/portal/admin/pending-applications/+page.svelte b/apps/www/src/routes/portal/admin/pending-applications/+page.svelte index df9c45e5..9b68993a 100644 --- a/apps/www/src/routes/portal/admin/pending-applications/+page.svelte +++ b/apps/www/src/routes/portal/admin/pending-applications/+page.svelte @@ -24,26 +24,27 @@ {/if} {#if data.pendingApplications.length === 0} -
+

Ingen ventende søknader

{:else}
{#each data.pendingApplications as application (application.id)} -
-
+
+

{application.name}

-

{application.email}

-

+

{application.email}

+

Søkte: {normalDate(application.createdAt)}

-
+
{ processingId = application.id; return async ({ update }) => { @@ -61,6 +62,7 @@ type="submit" intent="primary" size="sm" + class="w-full sm:w-auto" disabled={processingId === application.id} > {processingId === application.id ? 'Behandler...' : 'Godkjenn'} @@ -70,6 +72,7 @@ { processingId = application.id; return async ({ update }) => { @@ -86,6 +89,7 @@ type="submit" intent="danger" size="sm" + class="w-full sm:w-auto" disabled={processingId === application.id} > {processingId === application.id ? 'Behandler...' : 'Avslå'} diff --git a/apps/www/src/routes/portal/admin/user/[id]/+page.server.ts b/apps/www/src/routes/portal/admin/user/[id]/+page.server.ts index 26a3c78c..1f524792 100644 --- a/apps/www/src/routes/portal/admin/user/[id]/+page.server.ts +++ b/apps/www/src/routes/portal/admin/user/[id]/+page.server.ts @@ -1,7 +1,52 @@ +import { error } from '@sveltejs/kit'; +import type { PageServerLoad, Actions } from './$types'; import { fail } from '@sveltejs/kit'; -import type { Actions } from './$types'; + +export const load: PageServerLoad = async ({ params, locals }) => { + const userId = params.id; + + if (!locals.user || locals.user.role !== 'board') { + throw error(401, 'Unauthorized'); + } + + if (!userId) { + throw error(404, 'User ID not provided'); + } + + const user = await locals.userService.findById(userId); + if (!user) { + throw error(404, 'User not found'); + } + + const userShifts = await locals.shiftService.findCompletedShiftsByUserId(userId); + const unclaimedBeers = await locals.beerService.getTotalAvailableBeers(userId); + const referrals = await locals.referralService.getReferralStats(userId); + const shifts = await locals.shiftService.findUpcomingShiftsByUserId(userId); + + return { + user, + timesVolunteered: userShifts.length, + unclaimedBeers, + referrals, + shifts + }; +}; export const actions: Actions = { + updateUser: async ({ params, request, locals }) => { + const userId = params.id; + const formData = await request.formData(); + const role = formData.get('role')?.toString() as 'board' | 'normal'; + const phone = formData.get('phone')?.toString(); + if (phone) { + await locals.userService.updatePhone(userId, phone); + } + if (role) { + await locals.userService.updateUserRole(userId, role); + } + return { success: true }; + }, + addBeers: async ({ params, request, locals }) => { const userId = params.id; if (!locals.user || locals.user.role !== 'board') { @@ -34,7 +79,6 @@ export const actions: Actions = { const confirmDelete = formData.get('confirmDelete')?.toString(); const formUserId = formData.get('userId')?.toString(); - // Use user ID from form data or fallback to params const userId = formUserId || params.id; if (!userId) { @@ -55,7 +99,7 @@ export const actions: Actions = { if (confirmDelete !== user.name) { return fail(400, { success: false, - message: "Names dosen't match" + message: "Names doesn't match" }); } @@ -74,6 +118,41 @@ export const actions: Actions = { }); } - return { success: true }; + return { success: true, message: `${user.name} er no slettet!` }; + }, + + completeTraining: async ({ params, request, locals }) => { + const userId = params.id; + const formData = await request.formData(); + const trainingDataJson = formData.get('trainingData') as string; + + if (!userId) { + return fail(400, { error: 'User ID is required' }); + } + + if (!locals.user || locals.user.role !== 'board') { + return fail(401, { error: 'Unauthorized' }); + } + + if (!trainingDataJson) { + return fail(400, { error: 'Training data is required' }); + } + + const trainingData = JSON.parse(trainingDataJson); + + const isComplete = + trainingData && trainingData.every((item: { completed: boolean }) => item.completed === true); + + if (!isComplete) { + return fail(400, { error: 'All training items must be completed' }); + } + + const updatedUser = await locals.userService.updateTrainingStatus(userId, true); + + if (!updatedUser) { + return fail(404, { error: 'User not found' }); + } + + return { success: true, trainingCompleted: true }; } }; diff --git a/apps/www/src/routes/portal/admin/user/[id]/+page.svelte b/apps/www/src/routes/portal/admin/user/[id]/+page.svelte new file mode 100644 index 00000000..79f6e56f --- /dev/null +++ b/apps/www/src/routes/portal/admin/user/[id]/+page.svelte @@ -0,0 +1,464 @@ + + + + Admin - {user.name} + + +
+ + ← Tilbake til admin page + + +
+
+
+
+ + {initials(data.user.name)} + +
+
+ {user.name} +
+ + {user.role === 'board' ? 'Styret' : 'Frivillig'} + +
+
+
+
+ {#if !isEditing} + + {:else} + + + { + isSubmitting = true; + return async ({ result }) => { + isSubmitting = false; + if (result.type === 'success') { + user = { ...user, ...editForm }; + isEditing = false; + showToast(`${user.name} oppdatert`); + } else { + console.error('Failed to save user'); + showToast('Feil ved lagring'); + } + }; + }} + > + + + + + + + {/if} +
+
+
+ +
+
+
+
+

Brukerinformasjon

+
+
+ {#if isEditing} +
+
+
Navn
+
{data.user.name}
+
+
+ + +
+
+ + +
+
+
Rolle
+
+ + + +
+
+
+ {:else} +
+
+
Navn
+
{user.name}
+
+
+
E-post
+
{user.altEmail || user.email}
+
+
+
Telefon
+
{user.phone || 'Ikke oppgitt'}
+
+
+
Rolle
+
+ + {user.role === 'board' ? 'Styret' : 'Frivillig'} + +
+
+
+ {/if} +
+
+ +
+
+

Verv stats

+
+
+
+
+
+
+

Totale referreinger

+

{data.referrals.totalReferrals}

+
+
+
+
+
+

Godkjente referreninger

+

{data.referrals.completedReferrals}

+
+
+
+
+
+

Ventende referreringer

+

{data.referrals.pendingReferrals}

+
+
+
+
+
+
+ +
+
+
+

Statistikk

+
+
+
+ Antall ganger stått (sem) + {data.timesVolunteered || 0} +
+
+ Antall Bonger + {data.unclaimedBeers || 0} +
+
+ Kommende arrangement + + {data.shifts?.length > 0 ? data.shifts[0].event?.name : 'Ingen'} + +
+
+
+ +
+
+

Handlinger

+
+
+ + 📧 Send e-post + + + +
+ +
+
+
+
+
+
+ + + (showTrainingChecklist = false)} + onsave={onTrainingSave} +/> + +{#if showAddBeers} +
+
+

Legg til øl

+

+ Det du skriver her, vil endre på antall ekstra bonger {user.name} har tilgjengelig. +

+

Påvirker ikke antall bonger som dei har stått for

+
{ + return async ({ result }) => { + if (result.type === 'success') { + showAddBeers = false; + window.location.reload(); + } + }; + }} + > +
+ +
+
+ + +
+
+
+
+{/if} + +{#if showDeleteConfirm} +
+
+

Slett bruker

+

+ Er du sikker på at du vil slette {user.name}? Skriv inn brukerens navn for + å bekrefte. +

+
{ + return async ({ result }) => { + if (result.type === 'success') { + showDeleteConfirm = false; + deleteConfirmName = ''; + showToast((result.data as { message: string }).message); + setTimeout(() => { + goto('/portal/admin'); + }, 2000); + } else { + console.error('Failed to delete user'); + } + }; + }} + > +
+ +
+
+ + +
+
+
+
+{/if} + +{#if toastMessage} +
+ {toastMessage} +
+{/if} diff --git a/apps/www/src/routes/portal/admin/user/[id]/+server.ts b/apps/www/src/routes/portal/admin/user/[id]/+server.ts deleted file mode 100644 index 1a1abf85..00000000 --- a/apps/www/src/routes/portal/admin/user/[id]/+server.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { json, error } from '@sveltejs/kit'; -import type { RequestHandler } from './$types'; - -export const GET: RequestHandler = async ({ params, locals }) => { - const userId = params.id; - - if (!locals.user || locals.user.role !== 'board') { - throw error(401, 'Unauthorized'); - } - - const user = await locals.userService.findById(userId); - - if (!user) { - throw error(404, 'User not found'); - } - - const userShifts = await locals.shiftService.findCompletedShiftsByUserId(userId); - const unclaimedBeers = await locals.beerService.getTotalAvailableBeers(userId); - - return json({ - ...user, - timesVolunteered: userShifts.length, - unclaimedBeers: unclaimedBeers - }); -}; diff --git a/apps/www/src/routes/portal/profil/+page.server.ts b/apps/www/src/routes/portal/profil/+page.server.ts index f86d398e..298e8915 100644 --- a/apps/www/src/routes/portal/profil/+page.server.ts +++ b/apps/www/src/routes/portal/profil/+page.server.ts @@ -7,8 +7,17 @@ export const load: PageServerLoad = async ({ locals }) => { throw redirect(307, '/login'); } const user = await locals.userService.findById(locals.user.id); + const userShifts = await locals.shiftService.findCompletedShiftsByUserId(locals.user.id); + const unclaimedBeers = await locals.beerService.getTotalAvailableBeers(locals.user.id); + const referrals = await locals.referralService.getReferralStats(locals.user.id); + const shifts = await locals.shiftService.findUpcomingShiftsByUserId(locals.user.id); + return { - user + user, + timesVolunteered: userShifts.length, + unclaimedBeers, + referrals, + shifts }; }; @@ -17,29 +26,37 @@ export const actions: Actions = { if (!locals.user) { throw redirect(307, '/login'); } + const userId = locals.user.id; const data = await request.formData(); const altEmail = data.get('altEmail') as string; + const phone = data.get('phone') as string; - if (!isValidEmail(altEmail)) { - return fail(400, { - success: false, - message: 'Ugyldig e-postadresse', - altEmail - }); - } + if (altEmail) { + if (!isValidEmail(altEmail)) { + return fail(400, { + success: false, + message: 'Ugyldig e-postadresse', + altEmail + }); + } - const success = await locals.userService.updateAltEmail(locals.user.id, altEmail); - if (!success) { - return fail(500, { - success: false, - message: 'Kunne ikke oppdatere e-postadresse', - altEmail - }); + const mail = await locals.userService.updateAltEmail(userId, altEmail); + + if (!mail) { + return fail(500, { + success: false, + message: 'Kunne ikke oppdatere e-postadresse', + altEmail + }); + } } + if (phone) { + await locals.userService.updatePhone(userId, phone); + } return { success: true, - message: 'E-postadresse er oppdatert!' + message: 'Bruker er oppdatert!' }; } }; diff --git a/apps/www/src/routes/portal/profil/+page.svelte b/apps/www/src/routes/portal/profil/+page.svelte index 2203dbc7..b6555397 100644 --- a/apps/www/src/routes/portal/profil/+page.svelte +++ b/apps/www/src/routes/portal/profil/+page.svelte @@ -1,63 +1,261 @@ Min Profil -
-
-
-
-
-

Profilinnstillinger

-

Oppdater din informasjon og innstillinger

+ +
+
+
+
+
+ + {initials(data.user.name)} + +
+
+ {user.name} +
+ + {user.role === 'board' ? 'Styret' : 'Frivillig'} + +
+
+ {#if !isEditing} + + {:else} + + +
{ + isSubmitting = true; + return async ({ result }) => { + isSubmitting = false; + if (result.type === 'success') { + user = { ...user, ...editForm }; + isEditing = false; + showToast('Profil oppdatert'); + } else { + console.error('Failed to save profile'); + showToast('Feil ved lagring'); + } + }; + }} + > + + + + +
+ {/if} +
-
- {#if form?.message} -
-

{form.message}

-
- {/if} -
-
-
-
-

- Kontaktinformasjon -

-

Oppdater din alternative e-postadresse

+
+ +
+
+
+
+

Brukerinformasjon

+
+
+ {#if isEditing} +
+
+
Navn
+
{data.user.name}
+
+
+
Hovedepost
+
{data.user.email}
+
+
+ + +
+
+ + +
+
+ {:else} +
+
+
Navn
+
{user.name}
+
+
+
Hovedepost
+
{user.email}
+
+
+
Alternativ e-post
+
{user.altEmail || 'Ikke oppgitt'}
+
+
+
Telefon
+
{user.phone || 'Ikke oppgitt'}
+
+
+
Rolle
+
+ + {user.role === 'board' ? 'Styret' : 'Frivillig'} + +
+
+
+
Opplæring
+
+ + {user.isTrained ? 'Fullført' : 'Ikke fullført'} + +
+
+
+ {/if} +
+
+ +
+
+

Verv stats

+
+
+
+
+
+
+

Totale referreringer

+

{data.referrals.totalReferrals}

+
-
- +
+
+
+

Godkjente referreringer

+

{data.referrals.completedReferrals}

+
+
+
+
+
+

Ventende referreringer

+

{data.referrals.pendingReferrals}

+
-
- +
+
+ +
+
+
+

Statistikk

- +
+
+ Antall ganger stått (sem) + {data.timesVolunteered || 0} +
+
+ Antall Bonger + {data.unclaimedBeers || 0} +
+
+ Kommende arrangement + + {data.shifts?.length > 0 ? data.shifts[0].event?.name : 'Ingen'} + +
+
+
+ +{#if toastMessage} +
+ {toastMessage} +
+{/if}