-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #998 from parlemonde/VIL-586
Vil 586
- Loading branch information
Showing
9 changed files
with
137 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
server/migrations/1729236109909-AddCreatedAtColumnToStudentAndUserEntities.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import { TableColumn } from 'typeorm'; | ||
import type { MigrationInterface, QueryRunner } from 'typeorm'; | ||
|
||
export class AddCreatedAtColumnToStudentAndUserEntities1729236109909 implements MigrationInterface { | ||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.addColumn( | ||
'student', | ||
new TableColumn({ | ||
name: 'createdAt', | ||
type: 'timestamp', | ||
isNullable: true, | ||
}), | ||
); | ||
await queryRunner.query('UPDATE `student` SET `createdAt` = NULL WHERE `createdAt` IS NOT NULL'); | ||
await queryRunner.changeColumn( | ||
'student', | ||
'createdAt', | ||
new TableColumn({ | ||
name: 'createdAt', | ||
type: 'timestamp', | ||
isNullable: false, | ||
default: 'CURRENT_TIMESTAMP', | ||
}), | ||
); | ||
await queryRunner.addColumn( | ||
'user', | ||
new TableColumn({ | ||
name: 'createdAt', | ||
type: 'timestamp', | ||
isNullable: true, | ||
}), | ||
); | ||
await queryRunner.query('UPDATE `user` SET `createdAt` = NULL WHERE `createdAt` IS NOT NULL'); | ||
await queryRunner.changeColumn( | ||
'user', | ||
'createdAt', | ||
new TableColumn({ | ||
name: 'createdAt', | ||
type: 'timestamp', | ||
isNullable: false, | ||
default: 'CURRENT_TIMESTAMP', | ||
}), | ||
); | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.dropColumn('student', 'createdAt'); | ||
await queryRunner.dropColumn('user', 'createdAt'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters