From 3767f1a7870f148789a05828b98da1ad8a93578b Mon Sep 17 00:00:00 2001 From: Thibault Guillou Date: Tue, 17 Dec 2024 15:06:40 +0100 Subject: [PATCH] typescript error --- ...1720537502381-AlterAnalyticSessionTable.ts | 58 ------------------- ...71-AlterAnalyticSessionWithUserAndPhase.ts | 50 ---------------- 2 files changed, 108 deletions(-) delete mode 100644 server/migrations/1720537502381-AlterAnalyticSessionTable.ts delete mode 100644 server/migrations/1725362341071-AlterAnalyticSessionWithUserAndPhase.ts diff --git a/server/migrations/1720537502381-AlterAnalyticSessionTable.ts b/server/migrations/1720537502381-AlterAnalyticSessionTable.ts deleted file mode 100644 index 1bfce88ed..000000000 --- a/server/migrations/1720537502381-AlterAnalyticSessionTable.ts +++ /dev/null @@ -1,58 +0,0 @@ -import type { MigrationInterface, QueryRunner } from 'typeorm'; -import { TableColumn, TableForeignKey } from 'typeorm'; - -export class AlterAnalyticSessionTable1720537502381 implements MigrationInterface { - public async up(queryRunner: QueryRunner): Promise { - const table = await queryRunner.getTable('analytic_session'); - const isUserIdColumnExists = table?.findColumnByName('userId'); - const isPhaseColumnExists = table?.findColumnByName('phase'); - - if (!isUserIdColumnExists) { - await queryRunner.addColumn( - 'analytic_session', - new TableColumn({ - name: 'userId', - type: 'int', - isNullable: true, - }), - ); - - await queryRunner.createForeignKey( - 'analytic_session', - new TableForeignKey({ - columnNames: ['userId'], - referencedColumnNames: ['id'], - referencedTableName: 'user', - }), - ); - } - - if (!isPhaseColumnExists) { - await queryRunner.addColumn( - 'analytic_session', - new TableColumn({ - name: 'phase', - type: 'int', - isNullable: false, - }), - ); - } - } - - public async down(queryRunner: QueryRunner): Promise { - const table = await queryRunner.getTable('analytic_session'); - const isUserIdColumnExists = table?.findColumnByName('userId'); - const isUserPhaseColumnExists = table?.findColumnByName('phase'); - - if (table) { - if (isUserIdColumnExists) { - const foreignKey = table.foreignKeys.find((fk) => fk.columnNames.indexOf('userId') !== -1); - if (foreignKey) await queryRunner.dropForeignKey('analytic_session', foreignKey); - await queryRunner.dropColumn('analytic_session', 'userId'); - } - if (isUserPhaseColumnExists) { - await queryRunner.dropColumn('analytic_session', 'phase'); - } - } - } -} diff --git a/server/migrations/1725362341071-AlterAnalyticSessionWithUserAndPhase.ts b/server/migrations/1725362341071-AlterAnalyticSessionWithUserAndPhase.ts deleted file mode 100644 index ae9d4b6cf..000000000 --- a/server/migrations/1725362341071-AlterAnalyticSessionWithUserAndPhase.ts +++ /dev/null @@ -1,50 +0,0 @@ -import type { MigrationInterface, QueryRunner } from 'typeorm'; -import { TableColumn, TableForeignKey } from 'typeorm'; - -export class AlterAnalyticSessionWithUserAndPhase1725362341071 implements MigrationInterface { - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.addColumn( - 'analytic_session', - new TableColumn({ - name: 'userId', - type: 'int', - isNullable: true, - }), - ); - - await queryRunner.addColumn( - 'analytic_session', - new TableColumn({ - name: 'phase', - type: 'int', - isNullable: false, - }), - ); - - await queryRunner.createForeignKey( - 'analytic_session', - new TableForeignKey({ - columnNames: ['userId'], - referencedColumnNames: ['id'], - referencedTableName: 'user', - }), - ); - } - - public async down(queryRunner: QueryRunner): Promise { - const table = await queryRunner.getTable('analytic_session'); - const isUserIdColumnExists = table?.findColumnByName('userId'); - const isUserPhaseColumnExists = table?.findColumnByName('phase'); - - if (table) { - if (isUserIdColumnExists) { - const foreignKey = table.foreignKeys.find((fk) => fk.columnNames.indexOf('userId') !== -1); - if (foreignKey) await queryRunner.dropForeignKey('analytic_session', foreignKey); - await queryRunner.dropColumn('analytic_session', 'userId'); - } - if (isUserPhaseColumnExists) { - await queryRunner.dropColumn('analytic_session', 'phase'); - } - } - } -}