-
Notifications
You must be signed in to change notification settings - Fork 3
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 #607 from Badminton-Apps/feat/2-period-change-enco…
…unter Feat/2 period change encounter
- Loading branch information
Showing
19 changed files
with
366 additions
and
207 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
111 changes: 111 additions & 0 deletions
111
database/migrations/20240828181837-second change date.js
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,111 @@ | ||
/* eslint-disable @typescript-eslint/no-var-requires */ | ||
'use strict'; | ||
|
||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
up: async (queryInterface, Sequelize) => { | ||
return queryInterface.sequelize.transaction(async (t) => { | ||
try { | ||
await queryInterface.renameColumn( | ||
{ | ||
schema: 'event', | ||
tableName: 'EventCompetitions', | ||
}, | ||
'changeCloseDate', | ||
'changeCloseDatePeriod1', | ||
{ transaction: t }, | ||
); | ||
|
||
await queryInterface.renameColumn( | ||
{ | ||
schema: 'event', | ||
tableName: 'EventCompetitions', | ||
}, | ||
'changeCloseRequestDate', | ||
'changeCloseRequestDatePeriod1', | ||
{ transaction: t }, | ||
); | ||
|
||
await queryInterface.addColumn( | ||
{ | ||
schema: 'event', | ||
tableName: 'EventCompetitions', | ||
}, | ||
'changeCloseDatePeriod2', | ||
{ | ||
type: Sequelize.DATE, | ||
defaultValue: null, | ||
allowNull: true, | ||
}, | ||
{ transaction: t }, | ||
); | ||
|
||
await queryInterface.addColumn( | ||
{ | ||
schema: 'event', | ||
tableName: 'EventCompetitions', | ||
}, | ||
'changeCloseRequestDatePeriod2', | ||
{ | ||
type: Sequelize.DATE, | ||
defaultValue: null, | ||
allowNull: true, | ||
}, | ||
{ transaction: t }, | ||
); | ||
|
||
|
||
} catch (err) { | ||
console.error('We errored with', err?.message ?? err); | ||
t.rollback(); | ||
} | ||
}); | ||
}, | ||
|
||
down: async (queryInterface) => { | ||
return queryInterface.sequelize.transaction(async (t) => { | ||
try { | ||
await queryInterface.renameColumn( | ||
{ | ||
schema: 'event', | ||
tableName: 'EventCompetitions', | ||
}, | ||
'changeCloseDatePeriod1', | ||
'changeCloseDate', | ||
{ transaction: t }, | ||
); | ||
|
||
await queryInterface.renameColumn( | ||
{ | ||
schema: 'event', | ||
tableName: 'EventCompetitions', | ||
}, | ||
'changeCloseRequestDatePeriod1', | ||
'changeCloseRequestDate', | ||
{ transaction: t }, | ||
); | ||
|
||
await queryInterface.removeColumn( | ||
{ | ||
schema: 'event', | ||
tableName: 'EventCompetitions', | ||
}, | ||
'changeCloseDatePeriod2', | ||
{ transaction: t }, | ||
); | ||
|
||
await queryInterface.removeColumn( | ||
{ | ||
schema: 'event', | ||
tableName: 'EventCompetitions', | ||
}, | ||
'changeCloseRequestDatePeriod2', | ||
{ transaction: t }, | ||
); | ||
} catch (err) { | ||
console.error('We errored with', err); | ||
t.rollback(); | ||
} | ||
}); | ||
}, | ||
}; |
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
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
Oops, something went wrong.