From e7e35120fa356ab667192e35bc3fb981ef5dc1e9 Mon Sep 17 00:00:00 2001 From: sgfost Date: Fri, 18 Oct 2024 13:00:13 -0700 Subject: [PATCH] chore: squash prolific study migrations --- ...7891252710-AddProlificParticipantPlayer.ts | 24 ------------------- ...81440232-AddProlificStudySologameSetup.ts} | 18 +++++++++++--- 2 files changed, 15 insertions(+), 27 deletions(-) delete mode 100644 server/src/migration/1727891252710-AddProlificParticipantPlayer.ts rename server/src/migration/{1726604412870-AddProlificSologameStudy.ts => 1729281440232-AddProlificStudySologameSetup.ts} (69%) diff --git a/server/src/migration/1727891252710-AddProlificParticipantPlayer.ts b/server/src/migration/1727891252710-AddProlificParticipantPlayer.ts deleted file mode 100644 index 6be973a8f..000000000 --- a/server/src/migration/1727891252710-AddProlificParticipantPlayer.ts +++ /dev/null @@ -1,24 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class AddProlificParticipantPlayer1727891252710 implements MigrationInterface { - name = 'AddProlificParticipantPlayer1727891252710' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "prolific_study_participant" ADD "prolificBaselinePlayerId" integer`); - await queryRunner.query(`ALTER TABLE "prolific_study_participant" ADD CONSTRAINT "UQ_da2b1f49f29eef7941ab06eca11" UNIQUE ("prolificBaselinePlayerId")`); - await queryRunner.query(`ALTER TABLE "prolific_study_participant" ADD "prolificVariablePlayerId" integer`); - await queryRunner.query(`ALTER TABLE "prolific_study_participant" ADD CONSTRAINT "UQ_b5a15c60ff91e4b754305c64137" UNIQUE ("prolificVariablePlayerId")`); - await queryRunner.query(`ALTER TABLE "prolific_study_participant" ADD CONSTRAINT "FK_da2b1f49f29eef7941ab06eca11" FOREIGN KEY ("prolificBaselinePlayerId") REFERENCES "solo_player"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE "prolific_study_participant" ADD CONSTRAINT "FK_b5a15c60ff91e4b754305c64137" FOREIGN KEY ("prolificVariablePlayerId") REFERENCES "solo_player"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "prolific_study_participant" DROP CONSTRAINT "FK_b5a15c60ff91e4b754305c64137"`); - await queryRunner.query(`ALTER TABLE "prolific_study_participant" DROP CONSTRAINT "FK_da2b1f49f29eef7941ab06eca11"`); - await queryRunner.query(`ALTER TABLE "prolific_study_participant" DROP CONSTRAINT "UQ_b5a15c60ff91e4b754305c64137"`); - await queryRunner.query(`ALTER TABLE "prolific_study_participant" DROP COLUMN "prolificVariablePlayerId"`); - await queryRunner.query(`ALTER TABLE "prolific_study_participant" DROP CONSTRAINT "UQ_da2b1f49f29eef7941ab06eca11"`); - await queryRunner.query(`ALTER TABLE "prolific_study_participant" DROP COLUMN "prolificBaselinePlayerId"`); - } - -} diff --git a/server/src/migration/1726604412870-AddProlificSologameStudy.ts b/server/src/migration/1729281440232-AddProlificStudySologameSetup.ts similarity index 69% rename from server/src/migration/1726604412870-AddProlificSologameStudy.ts rename to server/src/migration/1729281440232-AddProlificStudySologameSetup.ts index 40de8f170..91a18a1c0 100644 --- a/server/src/migration/1726604412870-AddProlificSologameStudy.ts +++ b/server/src/migration/1729281440232-AddProlificStudySologameSetup.ts @@ -1,10 +1,10 @@ import { MigrationInterface, QueryRunner } from "typeorm"; -export class AddProlificSologameStudy1726604412870 implements MigrationInterface { - name = 'AddProlificSologameStudy1726604412870' +export class AddProlificStudySologameSetup1729281440232 implements MigrationInterface { + name = 'AddProlificStudySologameSetup1729281440232' public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`CREATE TABLE "prolific_study_participant" ("id" SERIAL NOT NULL, "userId" integer NOT NULL, "prolificId" character varying NOT NULL, "studyId" integer NOT NULL, "prolificBaselineTreatmentId" integer NOT NULL, "prolificVariableTreatmentId" integer NOT NULL, CONSTRAINT "REL_2a288d9abbe25b1817c68c37d7" UNIQUE ("userId"), CONSTRAINT "PK_30d57ab554a381a7d364a257513" PRIMARY KEY ("id"))`); + await queryRunner.query(`CREATE TABLE "prolific_study_participant" ("id" SERIAL NOT NULL, "userId" integer NOT NULL, "prolificId" character varying NOT NULL, "studyId" integer NOT NULL, "prolificBaselineTreatmentId" integer NOT NULL, "prolificVariableTreatmentId" integer NOT NULL, "prolificBaselinePlayerId" integer, "prolificVariablePlayerId" integer, CONSTRAINT "REL_2a288d9abbe25b1817c68c37d7" UNIQUE ("userId"), CONSTRAINT "REL_da2b1f49f29eef7941ab06eca1" UNIQUE ("prolificBaselinePlayerId"), CONSTRAINT "REL_b5a15c60ff91e4b754305c6413" UNIQUE ("prolificVariablePlayerId"), CONSTRAINT "PK_30d57ab554a381a7d364a257513" PRIMARY KEY ("id"))`); await queryRunner.query(`CREATE TABLE "prolific_study" ("id" SERIAL NOT NULL, "isActive" boolean NOT NULL DEFAULT true, "description" character varying, "externalSurveyUrl" character varying, "studyId" character varying NOT NULL, "completionCode" character varying NOT NULL, CONSTRAINT "PK_3fcda1de03b25111b6584b63422" PRIMARY KEY ("id"))`); await queryRunner.query(`ALTER TABLE "solo_game_treatment" ADD "gameType" character varying NOT NULL DEFAULT 'freeplay'`); await queryRunner.query(`ALTER TABLE "solo_game_treatment" ADD "isLowResSystemHealth" boolean NOT NULL DEFAULT false`); @@ -20,17 +20,29 @@ export class AddProlificSologameStudy1726604412870 implements MigrationInterface await queryRunner.query(`ALTER TABLE "solo_mars_event_card" ALTER COLUMN "systemHealthMultiplier" SET DEFAULT '0'`); await queryRunner.query(`ALTER TABLE "solo_mars_event_card" ALTER COLUMN "pointsMultiplier" SET DEFAULT '0'`); await queryRunner.query(`ALTER TABLE "solo_mars_event_card" ALTER COLUMN "resourcesMultiplier" SET DEFAULT '0'`); + await queryRunner.query(`ALTER TABLE "solo_player" ADD CONSTRAINT "UQ_68410b02beb97d426ee11e523ec" UNIQUE ("gameId")`); + await queryRunner.query(`ALTER TABLE "solo_high_score" ADD CONSTRAINT "UQ_8d7898d5fad7b94e42b86cb7d92" UNIQUE ("gameId")`); + await queryRunner.query(`ALTER TABLE "solo_player" ADD CONSTRAINT "FK_68410b02beb97d426ee11e523ec" FOREIGN KEY ("gameId") REFERENCES "solo_game"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); await queryRunner.query(`ALTER TABLE "prolific_study_participant" ADD CONSTRAINT "FK_2a288d9abbe25b1817c68c37d74" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); await queryRunner.query(`ALTER TABLE "prolific_study_participant" ADD CONSTRAINT "FK_c75960626fca5f5a1c3508ff98f" FOREIGN KEY ("studyId") REFERENCES "prolific_study"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); await queryRunner.query(`ALTER TABLE "prolific_study_participant" ADD CONSTRAINT "FK_18b94ad2f7f5b4d7ead5e865864" FOREIGN KEY ("prolificBaselineTreatmentId") REFERENCES "solo_game_treatment"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); await queryRunner.query(`ALTER TABLE "prolific_study_participant" ADD CONSTRAINT "FK_9fe3e4ae5dc5a2ae09e7a4f4bcc" FOREIGN KEY ("prolificVariableTreatmentId") REFERENCES "solo_game_treatment"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "prolific_study_participant" ADD CONSTRAINT "FK_da2b1f49f29eef7941ab06eca11" FOREIGN KEY ("prolificBaselinePlayerId") REFERENCES "solo_player"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "prolific_study_participant" ADD CONSTRAINT "FK_b5a15c60ff91e4b754305c64137" FOREIGN KEY ("prolificVariablePlayerId") REFERENCES "solo_player"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); + await queryRunner.query(`ALTER TABLE "solo_high_score" ADD CONSTRAINT "FK_8d7898d5fad7b94e42b86cb7d92" FOREIGN KEY ("gameId") REFERENCES "solo_game"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`); } public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "solo_high_score" DROP CONSTRAINT "FK_8d7898d5fad7b94e42b86cb7d92"`); + await queryRunner.query(`ALTER TABLE "prolific_study_participant" DROP CONSTRAINT "FK_b5a15c60ff91e4b754305c64137"`); + await queryRunner.query(`ALTER TABLE "prolific_study_participant" DROP CONSTRAINT "FK_da2b1f49f29eef7941ab06eca11"`); await queryRunner.query(`ALTER TABLE "prolific_study_participant" DROP CONSTRAINT "FK_9fe3e4ae5dc5a2ae09e7a4f4bcc"`); await queryRunner.query(`ALTER TABLE "prolific_study_participant" DROP CONSTRAINT "FK_18b94ad2f7f5b4d7ead5e865864"`); await queryRunner.query(`ALTER TABLE "prolific_study_participant" DROP CONSTRAINT "FK_c75960626fca5f5a1c3508ff98f"`); await queryRunner.query(`ALTER TABLE "prolific_study_participant" DROP CONSTRAINT "FK_2a288d9abbe25b1817c68c37d74"`); + await queryRunner.query(`ALTER TABLE "solo_player" DROP CONSTRAINT "FK_68410b02beb97d426ee11e523ec"`); + await queryRunner.query(`ALTER TABLE "solo_high_score" DROP CONSTRAINT "UQ_8d7898d5fad7b94e42b86cb7d92"`); + await queryRunner.query(`ALTER TABLE "solo_player" DROP CONSTRAINT "UQ_68410b02beb97d426ee11e523ec"`); await queryRunner.query(`ALTER TABLE "solo_mars_event_card" ALTER COLUMN "resourcesMultiplier" DROP DEFAULT`); await queryRunner.query(`ALTER TABLE "solo_mars_event_card" ALTER COLUMN "pointsMultiplier" DROP DEFAULT`); await queryRunner.query(`ALTER TABLE "solo_mars_event_card" ALTER COLUMN "systemHealthMultiplier" DROP DEFAULT`);