Skip to content

Commit

Permalink
rename db tables to have more consistency (#434)
Browse files Browse the repository at this point in the history
* rename db tables to have more consistency

* fix renaming variables

* fix tests

* update property names

* drop db changes

* create new migration starting from vote model changes

* update github actions pnpm setup to v4 to stop breaking actions issue

* fix tests

---------

Co-authored-by: Martin Benedikt Busch <[email protected]>
  • Loading branch information
diegoalzate and MartinBenediktBusch authored Jul 3, 2024
1 parent e8aa5fc commit 7f9c676
Show file tree
Hide file tree
Showing 35 changed files with 1,873 additions and 151 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check-formatting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,4 +33,4 @@ jobs:
run: pnpm install

- name: Review formatting
run: pnpm format
run: pnpm format
2 changes: 1 addition & 1 deletion .github/workflows/deploy-development.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
70 changes: 70 additions & 0 deletions migrations/0027_stormy_silverclaw.sql
Original file line number Diff line number Diff line change
@@ -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 $$;
Loading

0 comments on commit 7f9c676

Please sign in to comment.