diff --git a/.github/workflows/check-formatting.yml b/.github/workflows/check-formatting.yml index a7d05777..56a739ce 100644 --- a/.github/workflows/check-formatting.yml +++ b/.github/workflows/check-formatting.yml @@ -20,7 +20,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v4 with: version: 8 - name: Setup Node.js environment @@ -33,4 +33,4 @@ jobs: run: pnpm install - name: Review formatting - run: pnpm format \ No newline at end of file + run: pnpm format diff --git a/.github/workflows/deploy-development.yml b/.github/workflows/deploy-development.yml index 4c00df52..c0d1456e 100644 --- a/.github/workflows/deploy-development.yml +++ b/.github/workflows/deploy-development.yml @@ -23,7 +23,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v4 with: version: 8 - name: Setup Node.js environment diff --git a/.github/workflows/deploy-production.yml b/.github/workflows/deploy-production.yml index 4759044f..f7226f4e 100644 --- a/.github/workflows/deploy-production.yml +++ b/.github/workflows/deploy-production.yml @@ -23,7 +23,7 @@ jobs: - name: Checkout code uses: actions/checkout@v4 - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v4 with: version: 8 - name: Setup Node.js environment diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 579c3eee..ff1afcd7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,7 +21,7 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v4 with: version: 8 - name: Setup Node.js environment diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3eca7847..fdc2e002 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -38,7 +38,7 @@ jobs: - name: Check out repository code uses: actions/checkout@v4 - - uses: pnpm/action-setup@v2 + - uses: pnpm/action-setup@v4 with: version: 8 - name: Setup Node.js environment diff --git a/migrations/0027_stormy_silverclaw.sql b/migrations/0027_stormy_silverclaw.sql new file mode 100644 index 00000000..9e028b22 --- /dev/null +++ b/migrations/0027_stormy_silverclaw.sql @@ -0,0 +1,70 @@ +ALTER TABLE "forum_questions" RENAME TO "questions";--> statement-breakpoint +ALTER TABLE "question_options" RENAME TO "options";--> statement-breakpoint +ALTER TABLE "comments" RENAME COLUMN "question_option_id" TO "option_id";--> statement-breakpoint +ALTER TABLE "questions" RENAME COLUMN "question_title" TO "title";--> statement-breakpoint +ALTER TABLE "questions" RENAME COLUMN "question_sub_title" TO "sub_title";--> statement-breakpoint +ALTER TABLE "options" RENAME COLUMN "option_title" TO "title";--> statement-breakpoint +ALTER TABLE "options" RENAME COLUMN "option_sub_title" TO "sub_title";--> statement-breakpoint +ALTER TABLE "comments" DROP CONSTRAINT "comments_question_option_id_question_options_id_fk"; +--> statement-breakpoint +ALTER TABLE "questions" DROP CONSTRAINT "forum_questions_cycle_id_cycles_id_fk"; +--> statement-breakpoint +ALTER TABLE "options" DROP CONSTRAINT "question_options_user_id_users_id_fk"; +--> statement-breakpoint +ALTER TABLE "options" DROP CONSTRAINT "question_options_registration_id_registrations_id_fk"; +--> statement-breakpoint +ALTER TABLE "options" DROP CONSTRAINT "question_options_question_id_forum_questions_id_fk"; +--> statement-breakpoint +ALTER TABLE "votes" DROP CONSTRAINT "votes_option_id_question_options_id_fk"; +--> statement-breakpoint +ALTER TABLE "votes" DROP CONSTRAINT "votes_question_id_forum_questions_id_fk"; +--> statement-breakpoint +ALTER TABLE "questions_to_group_categories" DROP CONSTRAINT "questions_to_group_categories_question_id_forum_questions_id_fk"; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "comments" ADD CONSTRAINT "comments_option_id_options_id_fk" FOREIGN KEY ("option_id") REFERENCES "public"."options"("id") ON DELETE no action ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "questions" ADD CONSTRAINT "questions_cycle_id_cycles_id_fk" FOREIGN KEY ("cycle_id") REFERENCES "public"."cycles"("id") ON DELETE no action ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "options" ADD CONSTRAINT "options_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "options" ADD CONSTRAINT "options_registration_id_registrations_id_fk" FOREIGN KEY ("registration_id") REFERENCES "public"."registrations"("id") ON DELETE no action ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "options" ADD CONSTRAINT "options_question_id_questions_id_fk" FOREIGN KEY ("question_id") REFERENCES "public"."questions"("id") ON DELETE no action ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "votes" ADD CONSTRAINT "votes_option_id_options_id_fk" FOREIGN KEY ("option_id") REFERENCES "public"."options"("id") ON DELETE no action ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "votes" ADD CONSTRAINT "votes_question_id_questions_id_fk" FOREIGN KEY ("question_id") REFERENCES "public"."questions"("id") ON DELETE no action ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; +--> statement-breakpoint +DO $$ BEGIN + ALTER TABLE "questions_to_group_categories" ADD CONSTRAINT "questions_to_group_categories_question_id_questions_id_fk" FOREIGN KEY ("question_id") REFERENCES "public"."questions"("id") ON DELETE no action ON UPDATE no action; +EXCEPTION + WHEN duplicate_object THEN null; +END $$; diff --git a/migrations/meta/0027_snapshot.json b/migrations/meta/0027_snapshot.json new file mode 100644 index 00000000..d8f89b05 --- /dev/null +++ b/migrations/meta/0027_snapshot.json @@ -0,0 +1,1647 @@ +{ + "id": "201665be-855d-4af0-8e69-731c400b4907", + "prevId": "3e25dac0-f63a-429e-beec-e0b014693359", + "version": "6", + "dialect": "postgresql", + "tables": { + "public.alerts": { + "name": "alerts", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "title": { + "name": "title", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(1024)", + "primaryKey": false, + "notNull": false + }, + "link": { + "name": "link", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "start_at": { + "name": "start_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "end_at": { + "name": "end_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.comments": { + "name": "comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "option_id": { + "name": "option_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "comments_user_id_users_id_fk": { + "name": "comments_user_id_users_id_fk", + "tableFrom": "comments", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "comments_option_id_options_id_fk": { + "name": "comments_option_id_options_id_fk", + "tableFrom": "comments", + "tableTo": "options", + "columnsFrom": [ + "option_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.cycles": { + "name": "cycles", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "start_at": { + "name": "start_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "end_at": { + "name": "end_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "varchar(20)", + "primaryKey": false, + "notNull": false, + "default": "'UPCOMING'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "cycles_event_id_events_id_fk": { + "name": "cycles_event_id_events_id_fk", + "tableFrom": "cycles", + "tableTo": "events", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.events": { + "name": "events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "require_approval": { + "name": "require_approval", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "description": { + "name": "description", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "link": { + "name": "link", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "registration_description": { + "name": "registration_description", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "image_url": { + "name": "image_url", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "event_display_rank": { + "name": "event_display_rank", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.federated_credentials": { + "name": "federated_credentials", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "provider": { + "name": "provider", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "subject": { + "name": "subject", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "federated_credentials_user_id_users_id_fk": { + "name": "federated_credentials_user_id_users_id_fk", + "tableFrom": "federated_credentials", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "provider_subject_idx": { + "name": "provider_subject_idx", + "nullsNotDistinct": false, + "columns": [ + "provider", + "subject" + ] + } + } + }, + "public.group_categories": { + "name": "group_categories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "user_can_create": { + "name": "user_can_create", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "user_can_view": { + "name": "user_can_view", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "required": { + "name": "required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "group_categories_event_id_events_id_fk": { + "name": "group_categories_event_id_events_id_fk", + "tableFrom": "group_categories", + "tableTo": "events", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.groups": { + "name": "groups", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "secret": { + "name": "secret", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "group_category_id": { + "name": "group_category_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "groups_group_category_id_group_categories_id_fk": { + "name": "groups_group_category_id_group_categories_id_fk", + "tableFrom": "groups", + "tableTo": "group_categories", + "columnsFrom": [ + "group_category_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "groups_secret_unique": { + "name": "groups_secret_unique", + "nullsNotDistinct": false, + "columns": [ + "secret" + ] + } + } + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "username": { + "name": "username", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "first_name": { + "name": "first_name", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "last_name": { + "name": "last_name", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "telegram": { + "name": "telegram", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "users_username_unique": { + "name": "users_username_unique", + "nullsNotDistinct": false, + "columns": [ + "username" + ] + }, + "users_email_unique": { + "name": "users_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + }, + "users_telegram_unique": { + "name": "users_telegram_unique", + "nullsNotDistinct": false, + "columns": [ + "telegram" + ] + } + } + }, + "public.registrations": { + "name": "registrations", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "varchar", + "primaryKey": false, + "notNull": false, + "default": "'DRAFT'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "registrations_user_id_users_id_fk": { + "name": "registrations_user_id_users_id_fk", + "tableFrom": "registrations", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "registrations_event_id_events_id_fk": { + "name": "registrations_event_id_events_id_fk", + "tableFrom": "registrations", + "tableTo": "events", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "registrations_group_id_groups_id_fk": { + "name": "registrations_group_id_groups_id_fk", + "tableFrom": "registrations", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.questions": { + "name": "questions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "cycle_id": { + "name": "cycle_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true + }, + "sub_title": { + "name": "sub_title", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "vote_model": { + "name": "vote_model", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true, + "default": "'COCM'" + }, + "show_score": { + "name": "show_score", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "questions_cycle_id_cycles_id_fk": { + "name": "questions_cycle_id_cycles_id_fk", + "tableFrom": "questions", + "tableTo": "cycles", + "columnsFrom": [ + "cycle_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.registration_field_options": { + "name": "registration_field_options", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "registration_field_id": { + "name": "registration_field_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "registration_field_options_registration_field_id_registration_fields_id_fk": { + "name": "registration_field_options_registration_field_id_registration_fields_id_fk", + "tableFrom": "registration_field_options", + "tableTo": "registration_fields", + "columnsFrom": [ + "registration_field_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.options": { + "name": "options", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "registration_id": { + "name": "registration_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "question_id": { + "name": "question_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "varchar(256)", + "primaryKey": false, + "notNull": true + }, + "sub_title": { + "name": "sub_title", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "accepted": { + "name": "accepted", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "vote_score": { + "name": "vote_score", + "type": "numeric", + "primaryKey": false, + "notNull": true, + "default": "'0.0'" + }, + "funding_request": { + "name": "funding_request", + "type": "numeric", + "primaryKey": false, + "notNull": false, + "default": "'0.0'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "options_user_id_users_id_fk": { + "name": "options_user_id_users_id_fk", + "tableFrom": "options", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "options_registration_id_registrations_id_fk": { + "name": "options_registration_id_registrations_id_fk", + "tableFrom": "options", + "tableTo": "registrations", + "columnsFrom": [ + "registration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "options_question_id_questions_id_fk": { + "name": "options_question_id_questions_id_fk", + "tableFrom": "options", + "tableTo": "questions", + "columnsFrom": [ + "question_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.votes": { + "name": "votes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "option_id": { + "name": "option_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "question_id": { + "name": "question_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "num_of_votes": { + "name": "num_of_votes", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "votes_user_id_users_id_fk": { + "name": "votes_user_id_users_id_fk", + "tableFrom": "votes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "votes_option_id_options_id_fk": { + "name": "votes_option_id_options_id_fk", + "tableFrom": "votes", + "tableTo": "options", + "columnsFrom": [ + "option_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "votes_question_id_questions_id_fk": { + "name": "votes_question_id_questions_id_fk", + "tableFrom": "votes", + "tableTo": "questions", + "columnsFrom": [ + "question_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.registration_fields": { + "name": "registration_fields", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "event_id": { + "name": "event_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "type": { + "name": "type", + "type": "varchar", + "primaryKey": false, + "notNull": true, + "default": "'TEXT'" + }, + "required": { + "name": "required", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "fields_display_rank": { + "name": "fields_display_rank", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "character_limit": { + "name": "character_limit", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "for_group": { + "name": "for_group", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "for_user": { + "name": "for_user", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "registration_fields_event_id_events_id_fk": { + "name": "registration_fields_event_id_events_id_fk", + "tableFrom": "registration_fields", + "tableTo": "events", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.registration_data": { + "name": "registration_data", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "registration_id": { + "name": "registration_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "registration_field_id": { + "name": "registration_field_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "registration_data_registration_id_registrations_id_fk": { + "name": "registration_data_registration_id_registrations_id_fk", + "tableFrom": "registration_data", + "tableTo": "registrations", + "columnsFrom": [ + "registration_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "registration_data_registration_field_id_registration_fields_id_fk": { + "name": "registration_data_registration_field_id_registration_fields_id_fk", + "tableFrom": "registration_data", + "tableTo": "registration_fields", + "columnsFrom": [ + "registration_field_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.users_to_groups": { + "name": "users_to_groups", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "group_id": { + "name": "group_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "group_category_id": { + "name": "group_category_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "users_to_groups_user_id_users_id_fk": { + "name": "users_to_groups_user_id_users_id_fk", + "tableFrom": "users_to_groups", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "users_to_groups_group_id_groups_id_fk": { + "name": "users_to_groups_group_id_groups_id_fk", + "tableFrom": "users_to_groups", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "users_to_groups_group_category_id_group_categories_id_fk": { + "name": "users_to_groups_group_category_id_group_categories_id_fk", + "tableFrom": "users_to_groups", + "tableTo": "group_categories", + "columnsFrom": [ + "group_category_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.user_attributes": { + "name": "user_attributes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "attribute_key": { + "name": "attribute_key", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "attribute_value": { + "name": "attribute_value", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "user_attributes_user_id_users_id_fk": { + "name": "user_attributes_user_id_users_id_fk", + "tableFrom": "user_attributes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.likes": { + "name": "likes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "comment_id": { + "name": "comment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "likes_user_id_users_id_fk": { + "name": "likes_user_id_users_id_fk", + "tableFrom": "likes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "likes_comment_id_comments_id_fk": { + "name": "likes_comment_id_comments_id_fk", + "tableFrom": "likes", + "tableTo": "comments", + "columnsFrom": [ + "comment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.notification_types": { + "name": "notification_types", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "value": { + "name": "value", + "type": "varchar(256)", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notification_types_value_unique": { + "name": "notification_types_value_unique", + "nullsNotDistinct": false, + "columns": [ + "value" + ] + } + } + }, + "public.users_to_notifications": { + "name": "users_to_notifications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "notification_type_id": { + "name": "notification_type_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "users_to_notifications_user_id_users_id_fk": { + "name": "users_to_notifications_user_id_users_id_fk", + "tableFrom": "users_to_notifications", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "users_to_notifications_notification_type_id_notification_types_id_fk": { + "name": "users_to_notifications_notification_type_id_notification_types_id_fk", + "tableFrom": "users_to_notifications", + "tableTo": "notification_types", + "columnsFrom": [ + "notification_type_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.questions_to_group_categories": { + "name": "questions_to_group_categories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "question_id": { + "name": "question_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "group_category_id": { + "name": "group_category_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": { + "questions_to_group_categories_question_id_questions_id_fk": { + "name": "questions_to_group_categories_question_id_questions_id_fk", + "tableFrom": "questions_to_group_categories", + "tableTo": "questions", + "columnsFrom": [ + "question_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "questions_to_group_categories_group_category_id_group_categories_id_fk": { + "name": "questions_to_group_categories_group_category_id_group_categories_id_fk", + "tableFrom": "questions_to_group_categories", + "tableTo": "group_categories", + "columnsFrom": [ + "group_category_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": {}, + "schemas": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/migrations/meta/_journal.json b/migrations/meta/_journal.json index 06671681..6cb5fc89 100644 --- a/migrations/meta/_journal.json +++ b/migrations/meta/_journal.json @@ -190,6 +190,13 @@ "when": 1719999199277, "tag": "0026_redundant_galactus", "breakpoints": true + }, + { + "idx": 27, + "version": "6", + "when": 1720035204142, + "tag": "0027_stormy_silverclaw", + "breakpoints": true } ] } \ No newline at end of file diff --git a/src/db/comments.ts b/src/db/comments.ts index e378c0d0..550184a4 100644 --- a/src/db/comments.ts +++ b/src/db/comments.ts @@ -1,13 +1,13 @@ import { relations } from 'drizzle-orm'; import { pgTable, timestamp, uuid, varchar } from 'drizzle-orm/pg-core'; -import { questionOptions } from './question-options'; +import { options } from './options'; import { users } from './users'; import { likes } from './likes'; export const comments = pgTable('comments', { id: uuid('id').primaryKey().defaultRandom(), userId: uuid('user_id').references(() => users.id), - questionOptionId: uuid('question_option_id').references(() => questionOptions.id), + optionId: uuid('option_id').references(() => options.id), value: varchar('value').notNull(), createdAt: timestamp('created_at').notNull().defaultNow(), updatedAt: timestamp('updated_at').notNull().defaultNow(), @@ -18,9 +18,9 @@ export const commentsRelations = relations(comments, ({ one, many }) => ({ fields: [comments.userId], references: [users.id], }), - questionOption: one(questionOptions, { - fields: [comments.questionOptionId], - references: [questionOptions.id], + option: one(options, { + fields: [comments.optionId], + references: [options.id], }), likes: many(likes), })); diff --git a/src/db/cycles.ts b/src/db/cycles.ts index 4d0549d4..834c0e01 100644 --- a/src/db/cycles.ts +++ b/src/db/cycles.ts @@ -1,6 +1,6 @@ import { relations } from 'drizzle-orm'; import { pgTable, timestamp, uuid, varchar } from 'drizzle-orm/pg-core'; -import { forumQuestions } from './forum-questions'; +import { questions } from './questions'; import { events } from './events'; export const cycles = pgTable('cycles', { @@ -17,7 +17,7 @@ export const cycles = pgTable('cycles', { }); export const cyclesRelations = relations(cycles, ({ many, one }) => ({ - forumQuestions: many(forumQuestions), + questions: many(questions), event: one(events, { fields: [cycles.eventId], references: [events.id], diff --git a/src/db/index.ts b/src/db/index.ts index eabeebc9..b8c5be0e 100644 --- a/src/db/index.ts +++ b/src/db/index.ts @@ -2,9 +2,9 @@ export * from './users'; export * from './federated-credentials'; export * from './registrations'; export * from './cycles'; -export * from './forum-questions'; +export * from './questions'; export * from './registration-field-options'; -export * from './question-options'; +export * from './options'; export * from './votes'; export * from './events'; export * from './registration-fields'; diff --git a/src/db/question-options.ts b/src/db/options.ts similarity index 61% rename from src/db/question-options.ts rename to src/db/options.ts index a9bd601d..4fd771e3 100644 --- a/src/db/question-options.ts +++ b/src/db/options.ts @@ -1,20 +1,20 @@ import { boolean, pgTable, timestamp, uuid, varchar, numeric } from 'drizzle-orm/pg-core'; -import { forumQuestions } from './forum-questions'; +import { questions } from './questions'; import { relations } from 'drizzle-orm'; import { votes } from './votes'; import { registrations } from './registrations'; import { comments } from './comments'; import { users } from './users'; -export const questionOptions = pgTable('question_options', { +export const options = pgTable('options', { id: uuid('id').primaryKey().defaultRandom(), userId: uuid('user_id').references(() => users.id), registrationId: uuid('registration_id').references(() => registrations.id), questionId: uuid('question_id') - .references(() => forumQuestions.id) + .references(() => questions.id) .notNull(), - optionTitle: varchar('option_title', { length: 256 }).notNull(), - optionSubTitle: varchar('option_sub_title'), + title: varchar('title', { length: 256 }).notNull(), + subTitle: varchar('sub_title'), accepted: boolean('accepted').default(false), voteScore: numeric('vote_score').notNull().default('0.0'), fundingRequest: numeric('funding_request').default('0.0'), @@ -22,21 +22,21 @@ export const questionOptions = pgTable('question_options', { updatedAt: timestamp('updated_at').notNull().defaultNow(), }); -export const questionOptionsRelations = relations(questionOptions, ({ one, many }) => ({ +export const questionOptionsRelations = relations(options, ({ one, many }) => ({ user: one(users, { - fields: [questionOptions.userId], + fields: [options.userId], references: [users.id], }), - forumQuestion: one(forumQuestions, { - fields: [questionOptions.questionId], - references: [forumQuestions.id], + question: one(questions, { + fields: [options.questionId], + references: [questions.id], }), registrations: one(registrations, { - fields: [questionOptions.registrationId], + fields: [options.registrationId], references: [registrations.id], }), comment: many(comments), votes: many(votes), })); -export type QuestionOption = typeof questionOptions.$inferSelect; +export type Option = typeof options.$inferSelect; diff --git a/src/db/questions-to-group-categories.ts b/src/db/questions-to-group-categories.ts index ef1af337..8ec5a880 100644 --- a/src/db/questions-to-group-categories.ts +++ b/src/db/questions-to-group-categories.ts @@ -1,13 +1,13 @@ import { pgTable, timestamp, uuid } from 'drizzle-orm/pg-core'; import { relations } from 'drizzle-orm'; import { groupCategories } from './group-categories'; -import { forumQuestions } from './forum-questions'; +import { questions } from './questions'; export const questionsToGroupCategories = pgTable('questions_to_group_categories', { id: uuid('id').primaryKey().defaultRandom(), questionId: uuid('question_id') .notNull() - .references(() => forumQuestions.id), + .references(() => questions.id), groupCategoryId: uuid('group_category_id').references(() => groupCategories.id), // Must be nullable (for now) because affiliation does not have a group category id. createdAt: timestamp('created_at').notNull().defaultNow(), updatedAt: timestamp('updated_at').notNull().defaultNow(), @@ -16,9 +16,9 @@ export const questionsToGroupCategories = pgTable('questions_to_group_categories export const questionsToGroupCategoriesRelations = relations( questionsToGroupCategories, ({ one }) => ({ - question: one(forumQuestions, { + question: one(questions, { fields: [questionsToGroupCategories.questionId], - references: [forumQuestions.id], + references: [questions.id], }), groupCategory: one(groupCategories, { fields: [questionsToGroupCategories.groupCategoryId], diff --git a/src/db/forum-questions.ts b/src/db/questions.ts similarity index 60% rename from src/db/forum-questions.ts rename to src/db/questions.ts index 031d1200..97530241 100644 --- a/src/db/forum-questions.ts +++ b/src/db/questions.ts @@ -1,29 +1,29 @@ import { boolean, pgTable, timestamp, uuid, varchar } from 'drizzle-orm/pg-core'; import { cycles } from './cycles'; import { relations } from 'drizzle-orm'; -import { questionOptions } from './question-options'; +import { options } from './options'; import { questionsToGroupCategories } from './questions-to-group-categories'; -export const forumQuestions = pgTable('forum_questions', { +export const questions = pgTable('questions', { id: uuid('id').primaryKey().defaultRandom(), cycleId: uuid('cycle_id') .references(() => cycles.id) .notNull(), - questionTitle: varchar('question_title', { length: 256 }).notNull(), - questionSubTitle: varchar('question_sub_title', { length: 256 }), + title: varchar('title', { length: 256 }).notNull(), + subTitle: varchar('sub_title', { length: 256 }), voteModel: varchar('vote_model', { length: 256 }).notNull().default('COCM'), showScore: boolean('show_score').default(false), createdAt: timestamp('created_at').notNull().defaultNow(), updatedAt: timestamp('updated_at').notNull().defaultNow(), }); -export const forumQuestionsRelations = relations(forumQuestions, ({ one, many }) => ({ +export const forumQuestionsRelations = relations(questions, ({ one, many }) => ({ cycle: one(cycles, { - fields: [forumQuestions.cycleId], + fields: [questions.cycleId], references: [cycles.id], }), - questionOptions: many(questionOptions), + options: many(options), questionsToGroupCategories: many(questionsToGroupCategories), })); -export type ForumQuestion = typeof forumQuestions.$inferSelect; +export type Question = typeof questions.$inferSelect; diff --git a/src/db/users.ts b/src/db/users.ts index 07e19ff2..9317c47c 100644 --- a/src/db/users.ts +++ b/src/db/users.ts @@ -3,7 +3,7 @@ import { pgTable, timestamp, uuid, varchar } from 'drizzle-orm/pg-core'; import { federatedCredentials } from './federated-credentials'; import { comments } from './comments'; import { likes } from './likes'; -import { questionOptions } from './question-options'; +import { options } from './options'; import { registrations } from './registrations'; import { userAttributes } from './user-attributes'; import { usersToGroups } from './users-to-groups'; @@ -29,7 +29,7 @@ export const usersRelations = relations(users, ({ many, one }) => ({ federatedCredential: one(federatedCredentials), comments: many(comments), likes: many(likes), - questionOptions: many(questionOptions), + options: many(options), notifications: many(usersToNotifications), })); diff --git a/src/db/votes.ts b/src/db/votes.ts index ebedb537..fd77f846 100644 --- a/src/db/votes.ts +++ b/src/db/votes.ts @@ -1,8 +1,8 @@ import { integer, pgTable, timestamp, uuid } from 'drizzle-orm/pg-core'; import { users } from './users'; import { relations } from 'drizzle-orm'; -import { questionOptions } from './question-options'; -import { forumQuestions } from './forum-questions'; +import { options } from './options'; +import { questions } from './questions'; export const votes = pgTable('votes', { id: uuid('id').primaryKey().defaultRandom(), @@ -11,10 +11,10 @@ export const votes = pgTable('votes', { .references(() => users.id), optionId: uuid('option_id') .notNull() - .references(() => questionOptions.id), + .references(() => options.id), questionId: uuid('question_id') .notNull() - .references(() => forumQuestions.id), + .references(() => questions.id), numOfVotes: integer('num_of_votes').notNull(), createdAt: timestamp('created_at').notNull().defaultNow(), updatedAt: timestamp('updated_at').notNull().defaultNow(), @@ -25,13 +25,13 @@ export const votesRelations = relations(votes, ({ one }) => ({ fields: [votes.userId], references: [users.id], }), - questionOptions: one(questionOptions, { + option: one(options, { fields: [votes.optionId], - references: [questionOptions.id], + references: [options.id], }), - forumQuestion: one(forumQuestions, { + question: one(questions, { fields: [votes.questionId], - references: [forumQuestions.id], + references: [questions.id], }), })); diff --git a/src/handlers/comments.ts b/src/handlers/comments.ts index 66005625..ea5e0a9e 100644 --- a/src/handlers/comments.ts +++ b/src/handlers/comments.ts @@ -85,7 +85,7 @@ export function saveCommentHandler(dbPool: NodePgDatabase) { return res.status(400).json({ errors: body.error.issues }); } - const canComment = await userCanComment(dbPool, userId, body.data.questionOptionId); + const canComment = await userCanComment(dbPool, userId, body.data.optionId); if (!canComment) { return res.status(403).json({ errors: [{ message: 'User cannot comment on this option' }] }); diff --git a/src/handlers/cycles.ts b/src/handlers/cycles.ts index 911d9932..4e383f33 100644 --- a/src/handlers/cycles.ts +++ b/src/handlers/cycles.ts @@ -9,13 +9,13 @@ export function getActiveCyclesHandler(dbPool: NodePgDatabase) { const activeCycles = await dbPool.query.cycles.findMany({ where: and(lte(db.cycles.startAt, new Date()), gte(db.cycles.endAt, new Date())), with: { - forumQuestions: { + questions: { with: { - questionOptions: { + options: { columns: { voteScore: false, }, - where: eq(db.questionOptions.accepted, true), + where: eq(db.options.accepted, true), }, }, }, diff --git a/src/handlers/events.ts b/src/handlers/events.ts index d2058b25..743b9069 100644 --- a/src/handlers/events.ts +++ b/src/handlers/events.ts @@ -14,13 +14,13 @@ export function getEventCyclesHandler(dbPool: NodePgDatabase) { const eventCycles = await dbPool.query.cycles.findMany({ where: eq(db.cycles.eventId, eventId), with: { - forumQuestions: { + questions: { with: { - questionOptions: { + options: { columns: { voteScore: false, }, - where: eq(db.questionOptions.accepted, true), + where: eq(db.options.accepted, true), }, }, }, diff --git a/src/handlers/options.ts b/src/handlers/options.ts index ee065ce1..b4faadf8 100644 --- a/src/handlers/options.ts +++ b/src/handlers/options.ts @@ -12,14 +12,14 @@ export function getOptionHandler(dbPool: NodePgDatabase) { return res.status(400).json({ error: 'Missing optionId' }); } - const { voteScore, ...rest } = getTableColumns(db.questionOptions); + const { voteScore, ...rest } = getTableColumns(db.options); const rows = await dbPool .select({ ...rest, }) - .from(db.questionOptions) - .where(eq(db.questionOptions.id, optionId)); + .from(db.options) + .where(eq(db.options.id, optionId)); if (!rows.length) { return res.status(404).json({ error: 'Option not found' }); diff --git a/src/handlers/forum-questions.ts b/src/handlers/questions.ts similarity index 100% rename from src/handlers/forum-questions.ts rename to src/handlers/questions.ts diff --git a/src/handlers/users.ts b/src/handlers/users.ts index 1cc33fde..fe607a39 100644 --- a/src/handlers/users.ts +++ b/src/handlers/users.ts @@ -164,11 +164,11 @@ export function getUserOptionsHandler(dbPool: NodePgDatabase) { return res.status(400).json({ error: 'Missing userId' }); } - const optionsQuery = await dbPool.query.questionOptions.findMany({ + const optionsQuery = await dbPool.query.options.findMany({ with: { - forumQuestion: true, + question: true, }, - where: eq(db.questionOptions.userId, userId), + where: eq(db.options.userId, userId), }); return res.json({ data: optionsQuery }); diff --git a/src/routers/api.ts b/src/routers/api.ts index e30e815b..29ea428a 100644 --- a/src/routers/api.ts +++ b/src/routers/api.ts @@ -7,7 +7,7 @@ import cors from 'cors'; import { usersRouter } from './users'; import { cyclesRouter } from './cycles'; import { eventsRouter } from './events'; -import { forumQuestionsRouter } from './forum-questions'; +import { forumQuestionsRouter } from './questions'; import { groupsRouter } from './groups'; import { commentsRouter } from './comments'; import { optionsRouter } from './options'; @@ -54,7 +54,7 @@ export function apiRouter({ router.use('/cycles', cyclesRouter({ dbPool })); router.use('/votes', votesRouter({ dbPool })); router.use('/events', eventsRouter({ dbPool })); - router.use('/forum-questions', forumQuestionsRouter({ dbPool })); + router.use('/questions', forumQuestionsRouter({ dbPool })); router.use('/groups', groupsRouter({ dbPool })); router.use('/comments', commentsRouter({ dbPool })); router.use('/options', optionsRouter({ dbPool })); diff --git a/src/routers/forum-questions.ts b/src/routers/questions.ts similarity index 95% rename from src/routers/forum-questions.ts rename to src/routers/questions.ts index e515a588..d52d5f46 100644 --- a/src/routers/forum-questions.ts +++ b/src/routers/questions.ts @@ -5,7 +5,7 @@ import { getCalculateFundingHandler, getQuestionHeartsHandler, getResultStatisticsHandler, -} from '../handlers/forum-questions'; +} from '../handlers/questions'; import { NodePgDatabase } from 'drizzle-orm/node-postgres'; const router = express.Router(); diff --git a/src/services/comments.spec.ts b/src/services/comments.spec.ts index 414fa51e..5396aeb6 100644 --- a/src/services/comments.spec.ts +++ b/src/services/comments.spec.ts @@ -14,7 +14,7 @@ describe('service: comments', () => { let dbConnection: Client; let groupRegistrationData: z.infer; let secretCategory: db.GroupCategory | undefined; - let questionOption: db.QuestionOption | undefined; + let questionOption: db.Option | undefined; let secretGroup: db.Group[]; let cycle: db.Cycle | undefined; let user: db.User | undefined; @@ -71,9 +71,9 @@ describe('service: comments', () => { // update question options await dbPool - .update(db.questionOptions) + .update(db.options) .set({ registrationId: registrationId!, userId: user?.id ?? '' }) - .where(eq(db.questionOptions.id, questionOption!.id)); + .where(eq(db.options.id, questionOption!.id)); // update secret group await dbPool.update(db.groups).set({ secret: '12345' }).where(eq(db.groups.id, secretGroupId)); diff --git a/src/services/comments.ts b/src/services/comments.ts index 371368d9..10813f72 100644 --- a/src/services/comments.ts +++ b/src/services/comments.ts @@ -22,7 +22,7 @@ export async function saveComment( .insert(db.comments) .values({ userId: userId, - questionOptionId: data.questionOptionId, + optionId: data.optionId, value: data.value, }) .returning(); @@ -80,13 +80,13 @@ export async function getOptionComments( .select() .from(db.comments) .leftJoin(db.users, eq(db.comments.userId, db.users.id)) - .where(eq(db.comments.questionOptionId, data.optionId)); + .where(eq(db.comments.optionId, data.optionId)); const commentsWithUserNames = rows.map((row) => { return { id: row.comments.id, userId: row.comments.userId, - questionOptionId: row.comments.questionOptionId, + optionId: row.comments.optionId, value: row.comments.value, createdAt: row.comments.createdAt, user: { @@ -205,15 +205,15 @@ export async function getOptionUsers( option_owner AS ( SELECT - question_options."id", users."id" AS "user_id", + options."id", users."id" AS "user_id", json_build_object( 'id', users."id", 'username', users."username", 'firstName', users."first_name", 'lastName', users."last_name" ) AS option_owner - FROM question_options - LEFT JOIN users ON question_options."user_id" = users."id" + FROM options + LEFT JOIN users ON options."user_id" = users."id" ), registrations_secret_groups AS ( @@ -225,16 +225,16 @@ export async function getOptionUsers( result AS ( SELECT - question_options."id" AS "optionId", - question_options."registration_id" AS "registrationId", - question_options."user_id" AS "userId", + options."id" AS "optionId", + options."registration_id" AS "registrationId", + options."user_id" AS "userId", option_owner."option_owner" AS "user", registrations_secret_groups."group_id" AS "groupId", registrations_secret_groups."users_in_group" AS "usersInGroup" - FROM question_options - LEFT JOIN registrations_secret_groups ON question_options."registration_id" = registrations_secret_groups."id" - LEFT JOIN option_owner ON question_options."user_id" = option_owner."user_id" - WHERE question_options."id" = '${optionId}' + FROM options + LEFT JOIN registrations_secret_groups ON options."registration_id" = registrations_secret_groups."id" + LEFT JOIN option_owner ON options."user_id" = option_owner."user_id" + WHERE options."id" = '${optionId}' ), nested_result AS ( diff --git a/src/services/cycles.spec.ts b/src/services/cycles.spec.ts index e5ad1bc8..1575a44d 100644 --- a/src/services/cycles.spec.ts +++ b/src/services/cycles.spec.ts @@ -11,8 +11,8 @@ describe('service: cycles', () => { let dbPool: NodePgDatabase; let dbConnection: Client; let cycle: db.Cycle | undefined; - let questionOption: db.QuestionOption | undefined; - let forumQuestion: db.ForumQuestion | undefined; + let questionOption: db.Option | undefined; + let forumQuestion: db.Question | undefined; let user: db.User | undefined; let secondUser: db.User | undefined; diff --git a/src/services/cycles.ts b/src/services/cycles.ts index 26e0f93d..5825fac4 100644 --- a/src/services/cycles.ts +++ b/src/services/cycles.ts @@ -6,9 +6,9 @@ export async function GetCycleById(dbPool: NodePgDatabase, cycleId: s const cycle = await dbPool.query.cycles.findFirst({ where: eq(db.cycles.id, cycleId), with: { - forumQuestions: { + questions: { with: { - questionOptions: { + options: { with: { user: { with: { @@ -27,7 +27,7 @@ export async function GetCycleById(dbPool: NodePgDatabase, cycleId: s }, }, }, - where: eq(db.questionOptions.accepted, true), + where: eq(db.options.accepted, true), }, }, }, @@ -36,15 +36,15 @@ export async function GetCycleById(dbPool: NodePgDatabase, cycleId: s const out = { ...cycle, - forumQuestions: cycle?.forumQuestions.map((question) => { + forumQuestions: cycle?.questions.map((question) => { return { ...question, - questionOptions: question.questionOptions.map((option) => { + questionOptions: question.options.map((option) => { return { id: option.id, accepted: option.accepted, - optionTitle: option.optionTitle, - optionSubTitle: option.optionSubTitle, + title: option.title, + subTitle: option.subTitle, questionId: option.questionId, voteScore: question.showScore ? option.voteScore : undefined, registrationId: option.registrationId, @@ -79,9 +79,9 @@ export async function getCycleVotes( ) { const response = await dbPool.query.cycles.findMany({ with: { - forumQuestions: { + questions: { with: { - questionOptions: { + options: { columns: { voteScore: false, }, @@ -104,9 +104,7 @@ export async function getCycleVotes( }); const out = response.flatMap((cycle) => - cycle.forumQuestions.flatMap((question) => - question.questionOptions.flatMap((option) => option.votes), - ), + cycle.questions.flatMap((question) => question.options.flatMap((option) => option.votes)), ); return out; diff --git a/src/services/funding-mechanism.ts b/src/services/funding-mechanism.ts index 85e52d0a..405801b0 100644 --- a/src/services/funding-mechanism.ts +++ b/src/services/funding-mechanism.ts @@ -17,12 +17,12 @@ export async function calculateFunding( ): Promise<{ allocated_funding: { [key: string]: number }; remaining_funding: number }> { const getOptionData = await dbPool .select({ - id: db.questionOptions.id, - voteScore: db.questionOptions.voteScore, - fundingRequest: db.questionOptions.fundingRequest, + id: db.options.id, + voteScore: db.options.voteScore, + fundingRequest: db.options.fundingRequest, }) - .from(db.questionOptions) - .where(eq(db.questionOptions.questionId, forumQuestionId)); + .from(db.options) + .where(eq(db.options.questionId, forumQuestionId)); if (!getOptionData) { throw new Error('Error in query getOptionData'); diff --git a/src/services/statistics.spec.ts b/src/services/statistics.spec.ts index a4c3c2e6..57eefa62 100644 --- a/src/services/statistics.spec.ts +++ b/src/services/statistics.spec.ts @@ -13,8 +13,8 @@ describe('service: statistics', () => { let dbConnection: Client; let userTestData: z.infer; let otherUserTestData: z.infer; - let questionOption: db.QuestionOption | undefined; - let forumQuestion: db.ForumQuestion | undefined; + let questionOption: db.Option | undefined; + let forumQuestion: db.Question | undefined; let user: db.User | undefined; let otherUser: db.User | undefined; @@ -83,8 +83,8 @@ describe('service: statistics', () => { for (const optionId in result.optionStats) { const optionStat = result.optionStats[optionId]; expect(optionStat).toBeDefined(); - expect(optionStat?.optionTitle).toBeDefined(); - expect(optionStat?.optionSubTitle).toBeDefined(); + expect(optionStat?.title).toBeDefined(); + expect(optionStat?.subTitle).toBeDefined(); expect(optionStat?.pluralityScore).toBeDefined(); expect(optionStat?.distinctUsers).toBeDefined(); expect(optionStat?.allocatedHearts).toBeDefined(); diff --git a/src/services/statistics.ts b/src/services/statistics.ts index 86bc1486..1fc476fd 100644 --- a/src/services/statistics.ts +++ b/src/services/statistics.ts @@ -10,8 +10,8 @@ type ResultData = { optionStats: Record< string, { - optionTitle: string; - optionSubTitle: string; + title: string; + subTitle: string; pluralityScore: string; distinctUsers: number; allocatedHearts: number; @@ -46,7 +46,7 @@ export async function executeResultQueries( dbPool.execute<{ numProposals: number }>( sql.raw(` SELECT count("id")::int AS "numProposals" - FROM question_options + FROM options WHERE question_id = '${forumQuestionId}' AND accepted = TRUE `), @@ -100,8 +100,8 @@ export async function executeResultQueries( // Get individual results dbPool.execute<{ optionId: string; - optionTitle: string; - optionSubTitle: string; + title: string; + subTitle: string; pluralityScore: string; distinctUsers: number; allocatedHearts: number; @@ -118,8 +118,8 @@ export async function executeResultQueries( ), plural_score_and_title AS ( - SELECT "id" AS "optionId", "option_title" AS "optionTitle", "option_sub_title" AS "optionSubTitle", vote_score AS "pluralityScore" - FROM question_options + SELECT "id" AS "optionId", "title" AS "title", "sub_title" AS "subTitle", vote_score AS "pluralityScore" + FROM options WHERE question_id = '${forumQuestionId}' AND accepted = TRUE -- makes sure to only expose data of accepted options ), @@ -189,8 +189,8 @@ export async function executeResultQueries( /* Aggregated results */ merged_result AS ( SELECT id_title_score."optionId", - id_title_score."optionTitle", - id_title_score."optionSubTitle", + id_title_score."title", + id_title_score."subTitle", id_title_score."pluralityScore", distinct_users."distinctUsers", hearts."allocatedHearts", @@ -221,8 +221,8 @@ export async function executeResultQueries( const indivStats: Record< string, { - optionTitle: string; - optionSubTitle: string; + title: string; + subTitle: string; pluralityScore: string; distinctUsers: number; allocatedHearts: number; @@ -236,8 +236,8 @@ export async function executeResultQueries( queryIndivStatistics.rows.forEach((row) => { const { optionId: indivOptionId, - optionTitle: indivOptionTitle, - optionSubTitle: indivOptionSubTitle, + title: indivOptionTitle, + subTitle: indivOptionSubTitle, pluralityScore: indivPluralityScore, distinctUsers: indivDistinctUsers, allocatedHearts: indivAllocatedHearts, @@ -247,8 +247,8 @@ export async function executeResultQueries( } = row; indivStats[indivOptionId] = { - optionTitle: indivOptionTitle || 'No Title Provided', - optionSubTitle: indivOptionSubTitle || '', + title: indivOptionTitle || 'No Title Provided', + subTitle: indivOptionSubTitle || '', pluralityScore: indivPluralityScore || '0.0', distinctUsers: indivDistinctUsers || 0, allocatedHearts: indivAllocatedHearts || 0, diff --git a/src/services/votes.spec.ts b/src/services/votes.spec.ts index d2b6b426..5f7e75ba 100644 --- a/src/services/votes.spec.ts +++ b/src/services/votes.spec.ts @@ -25,10 +25,10 @@ describe('service: votes', () => { let dbConnection: Client; let testData: z.infer; let cycle: db.Cycle | undefined; - let questionOption: db.QuestionOption | undefined; - let otherQuestionOption: db.QuestionOption | undefined; - let forumQuestion: db.ForumQuestion | undefined; - let otherForumQuestion: db.ForumQuestion | undefined; + let questionOption: db.Option | undefined; + let otherQuestionOption: db.Option | undefined; + let forumQuestion: db.Question | undefined; + let otherForumQuestion: db.Question | undefined; let groupCategory: db.GroupCategory | undefined; let otherGroupCategory: db.GroupCategory | undefined; let unrelatedGroupCategory: db.GroupCategory | undefined; @@ -325,8 +325,8 @@ describe('service: votes', () => { await updateVoteScoreInDatabase(dbPool, questionOption?.id ?? '', score); // query updated score in db - const updatedDbScore = await dbPool.query.questionOptions.findFirst({ - where: eq(db.questionOptions.id, questionOption?.id ?? ''), + const updatedDbScore = await dbPool.query.options.findFirst({ + where: eq(db.options.id, questionOption?.id ?? ''), }); expect(updatedDbScore?.voteScore).toBe('100'); diff --git a/src/services/votes.ts b/src/services/votes.ts index 416f7d91..e6e6bed1 100644 --- a/src/services/votes.ts +++ b/src/services/votes.ts @@ -37,8 +37,8 @@ export async function saveVotes( } } - const queryQuestionOption = await dbPool.query.questionOptions.findFirst({ - where: eq(db.questionOptions.id, voteData[0]!.optionId), + const queryQuestionOption = await dbPool.query.options.findFirst({ + where: eq(db.options.id, voteData[0]!.optionId), }); if (!queryQuestionOption) { @@ -46,8 +46,8 @@ export async function saveVotes( return { data: voteData, errors }; } - const queryForumQuestion = await dbPool.query.forumQuestions.findFirst({ - where: eq(db.forumQuestions.id, queryQuestionOption!.questionId), + const queryForumQuestion = await dbPool.query.questions.findFirst({ + where: eq(db.questions.id, queryQuestionOption!.questionId), }); if (!queryForumQuestion) { @@ -207,12 +207,12 @@ export async function updateVoteScoreInDatabase( ) { // Update vote score in the database await dbPool - .update(db.questionOptions) + .update(db.options) .set({ voteScore: score.toString(), updatedAt: new Date(), }) - .where(eq(db.questionOptions.id, optionId)); + .where(eq(db.options.id, optionId)); } /** @@ -236,10 +236,10 @@ export async function updateVoteScorePlural( // Query group data, grouping dimensions, and calculate the score const queryQuestionId = await dbPool .select({ - questionId: db.questionOptions.questionId, + questionId: db.options.questionId, }) - .from(db.questionOptions) - .where(eq(db.questionOptions.id, optionId)); + .from(db.options) + .where(eq(db.options.id, optionId)); const groupCategories = await queryGroupCategories(dbPool, queryQuestionId[0]!.questionId); const groupArray = await groupsDictionary(dbPool, votesDictionary, groupCategories ?? []); @@ -292,8 +292,8 @@ async function validateAndSaveVote( return { data: null, error: 'optionId is required' }; } - const queryQuestionOption = await dbPool.query.questionOptions.findFirst({ - where: eq(db.questionOptions.id, vote.optionId), + const queryQuestionOption = await dbPool.query.options.findFirst({ + where: eq(db.options.id, vote.optionId), }); if (!queryQuestionOption) { @@ -346,8 +346,8 @@ export async function saveVote( vote: z.infer, ) { // check if cycle is open - const queryQuestion = await dbPool.query.forumQuestions.findFirst({ - where: eq(db.forumQuestions.id, vote?.questionId ?? ''), + const queryQuestion = await dbPool.query.questions.findFirst({ + where: eq(db.questions.id, vote?.questionId ?? ''), with: { cycle: true, }, diff --git a/src/utils/db/seed-data-generators.ts b/src/utils/db/seed-data-generators.ts index db90ae30..70b489f6 100644 --- a/src/utils/db/seed-data-generators.ts +++ b/src/utils/db/seed-data-generators.ts @@ -2,10 +2,10 @@ import { randCompanyName, randCountry, randUser } from '@ngneat/falso'; import { Cycle, Event, - ForumQuestion, + Question, RegistrationField, RegistrationFieldOption, - QuestionOption, + Option, GroupCategory, Group, User, @@ -24,8 +24,8 @@ export type RegistrationFieldOptionData = Pick< RegistrationFieldOption, 'registrationFieldId' | 'value' >; -export type ForumQuestionData = Pick; -export type QuestionOptionData = Pick; +export type ForumQuestionData = Pick; +export type QuestionOptionData = Pick; export type GroupCategoryData = Pick< GroupCategory, 'name' | 'eventId' | 'userCanCreate' | 'userCanView' | 'required' @@ -95,9 +95,9 @@ export function generateForumQuestionData( questionTitles: string[], voteModels: string[], ): ForumQuestionData[] { - return questionTitles.map((questionTitle, index) => ({ + return questionTitles.map((title, index) => ({ cycleId, - questionTitle, + title, voteModel: voteModels[index] ?? 'COCM', })); } @@ -112,7 +112,7 @@ export function generateQuestionOptionsData( for (let i = 0; i < optionTitles.length; i++) { const optionData: QuestionOptionData = { questionId, - optionTitle: optionTitles[i]!, + title: optionTitles[i]!, accepted: status[i]!, }; questionOptionsData.push(optionData); diff --git a/src/utils/db/seed.ts b/src/utils/db/seed.ts index 3614998c..bf01456a 100644 --- a/src/utils/db/seed.ts +++ b/src/utils/db/seed.ts @@ -130,7 +130,7 @@ async function cleanup(dbPool: NodePgDatabase) { await dbPool.delete(db.userAttributes); await dbPool.delete(db.votes); await dbPool.delete(db.federatedCredentials); - await dbPool.delete(db.questionOptions); + await dbPool.delete(db.options); await dbPool.delete(db.registrationData); await dbPool.delete(db.registrationFieldOptions); await dbPool.delete(db.registrationFields); @@ -140,7 +140,7 @@ async function cleanup(dbPool: NodePgDatabase) { await dbPool.delete(db.groups); await dbPool.delete(db.questionsToGroupCategories); await dbPool.delete(db.groupCategories); - await dbPool.delete(db.forumQuestions); + await dbPool.delete(db.questions); await dbPool.delete(db.cycles); await dbPool.delete(db.events); } @@ -261,10 +261,10 @@ async function createForumQuestions( } const result = await dbPool - .insert(db.forumQuestions) + .insert(db.questions) .values({ cycleId: questionData.cycleId, - questionTitle: questionData.questionTitle, + title: questionData.title, voteModel: questionData.voteModel, }) .returning(); @@ -290,10 +290,10 @@ async function createQuestionOptions( } const result = await dbPool - .insert(db.questionOptions) + .insert(db.options) .values({ questionId: questionOption.questionId, - optionTitle: questionOption.optionTitle, + title: questionOption.title, accepted: questionOption.accepted, }) .returning();