Skip to content

Commit

Permalink
change migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard-Pentecost committed Jul 20, 2022
1 parent 6de5ca9 commit 29373e6
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions migrations/20220718113815-workerAuditTableAddIndexForUsername.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@

module.exports = {
up: async (queryInterface) => {
await queryInterface.addIndex(
{
tableName: 'WorkerAudit',
schema: 'cqc',
},
{
fields: ['Username'],
},
{
name: 'worker_audit__username_idx',
},
);
await queryInterface.sequelize.transaction(async (transaction) => {
await Promise.all([
queryInterface.sequelize.query('DROP INDEX IF EXISTS cqc."worker_audit__username";', { transaction }),
queryInterface.addIndex(
{
tableName: 'WorkerAudit',
schema: 'cqc',
},
{
fields: ['Username'],
},
),
]);
});
},

down: async (queryInterface) => {
Expand All @@ -22,7 +24,7 @@ module.exports = {
tableName: 'WorkerAudit',
schema: 'cqc',
},
'cqc."worker_audit__username_idx"',
'cqc."worker_audit__username"',
);
},
};

0 comments on commit 29373e6

Please sign in to comment.