-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* build(devdeps): add lodash types * fix(model): rectify db model definitions * refactor: add message param to ForbiddenError * feat: add CollaboratorsService * test: add tests for CollaboratorsService * feat: use CollaboratorService in authorization middleware * test: add tests for authorization middleware * feat: add CollaboratorsRouter * test: add tests for CollaboratorsRouter * feat(db-migration): change site_members role enum in the database * feat: modify authzMiddlewareService tests * fix: error in mock collaborators fixture
- Loading branch information
1 parent
83d1e84
commit 9a39600
Showing
22 changed files
with
1,522 additions
and
73 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
59 changes: 59 additions & 0 deletions
59
src/database/migrations/20220811070630-change-role-enum.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,59 @@ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
// Change the role enum values in the site_members table | ||
await queryInterface.sequelize.transaction(async (transaction) => { | ||
// 1. Change column type to TEXT | ||
await queryInterface.changeColumn( | ||
"site_members", // name of Source model | ||
"role", // name of column we're modifying | ||
{ | ||
type: Sequelize.TEXT, | ||
}, | ||
{ transaction } | ||
) | ||
// 2. Discard enum type | ||
await queryInterface.sequelize.query( | ||
"drop type enum_site_members_role;", | ||
{ transaction } | ||
) | ||
// 3. Change column type to new enum type (fails if inconsistent with existing data) | ||
await queryInterface.changeColumn( | ||
"site_members", // name of Source model | ||
"role", // name of column we're modifying | ||
{ | ||
type: Sequelize.ENUM("ADMIN", "CONTRIBUTOR"), | ||
}, | ||
{ transaction } | ||
) | ||
}) | ||
}, | ||
|
||
async down(queryInterface, Sequelize) { | ||
// Change the role enum values in the site_members table | ||
await queryInterface.sequelize.transaction(async (transaction) => { | ||
// 1. Change column type to TEXT | ||
await queryInterface.changeColumn( | ||
"site_members", // name of Source model | ||
"role", // name of column we're modifying | ||
{ | ||
type: Sequelize.TEXT, | ||
}, | ||
{ transaction } | ||
) | ||
// 2. Discard enum type | ||
await queryInterface.sequelize.query( | ||
"drop type enum_site_members_role;", | ||
{ transaction } | ||
) | ||
// 3. Change column type to new enum type (fails if inconsistent with existing data) | ||
await queryInterface.changeColumn( | ||
"site_members", // name of Source model | ||
"role", // name of column we're modifying | ||
{ | ||
type: Sequelize.ENUM("ADMIN", "USER"), | ||
}, | ||
{ transaction } | ||
) | ||
}) | ||
}, | ||
} |
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.