1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-11-28 14:58:29 +09:00
cherrypick/packages/backend/migration/1704185628000-note-updated-at2.js
2024-01-02 19:40:53 +09:00

21 lines
587 B
JavaScript

export class NoteUpdatedAt1704185628000 {
name = 'NoteUpdatedAt1704185628000'
async up(queryRunner) {
await queryRunner.query(`SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'note' AND column_name = 'updatedAt'`)
.then(updatedAt => {
if (updatedAt.length > 0) {
return [];
} else {
return [
queryRunner.query(`ALTER TABLE "note" ADD "updatedAt" TIMESTAMP WITH TIME ZONE`)
];
}
})
}
async down(queryRunner) {
await queryRunner.query(`ALTER TABLE "note" DROP COLUMN "updatedAt"`);
}
}