-
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.
* chore(infraservice): remove unused prop * chore(routes/auth): remove unused var * build(package): add useful command to undo migration * feat(migrations): add migrations for review requests fix(db migratino): update property names * chore(db migration): add migration to add status col to rr * chore(db migrations): add required columns for seq creation
- Loading branch information
Showing
7 changed files
with
164 additions
and
9 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
43 changes: 43 additions & 0 deletions
43
src/database/migrations/20221003052424-review-request-creation.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,43 @@ | ||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
await queryInterface.createTable("review_requests", { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: Sequelize.BIGINT, | ||
autoIncrement: true, | ||
}, | ||
requestor_id: { | ||
type: Sequelize.BIGINT, | ||
allowNull: false, | ||
references: { | ||
model: "users", | ||
key: "id", | ||
}, | ||
}, | ||
site_id: { | ||
type: Sequelize.BIGINT, | ||
allowNull: false, | ||
references: { | ||
model: "sites", | ||
key: "id", | ||
}, | ||
}, | ||
created_at: { | ||
type: Sequelize.DATE, | ||
allowNull: false, | ||
defaultValue: Sequelize.fn("NOW"), | ||
}, | ||
updated_at: { | ||
type: Sequelize.DATE, | ||
allowNull: false, | ||
defaultValue: Sequelize.fn("NOW"), | ||
}, | ||
}) | ||
}, | ||
|
||
async down(queryInterface, Sequelize) { | ||
await queryInterface.dropTable("review_requests") | ||
}, | ||
} |
46 changes: 46 additions & 0 deletions
46
src/database/migrations/20221003123422-review-meta-creation.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,46 @@ | ||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
async up(queryInterface, Sequelize) { | ||
await queryInterface.createTable("review_meta", { | ||
id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
type: Sequelize.BIGINT, | ||
}, | ||
review_id: { | ||
type: Sequelize.BIGINT, | ||
allowNull: false, | ||
references: { | ||
model: "review_requests", | ||
key: "id", | ||
}, | ||
}, | ||
// The PR number stored by GitHub | ||
pull_request_number: { | ||
type: Sequelize.BIGINT, | ||
allowNull: false, | ||
}, | ||
// The link to view this RR | ||
review_link: { | ||
unique: true, | ||
type: Sequelize.STRING, | ||
allowNull: false, | ||
}, | ||
created_at: { | ||
type: Sequelize.DATE, | ||
allowNull: false, | ||
defaultValue: Sequelize.fn("NOW"), | ||
}, | ||
updated_at: { | ||
type: Sequelize.DATE, | ||
allowNull: false, | ||
defaultValue: Sequelize.fn("NOW"), | ||
}, | ||
}) | ||
}, | ||
|
||
async down(queryInterface, Sequelize) { | ||
await queryInterface.dropTable("review_meta") | ||
}, | ||
} |
43 changes: 43 additions & 0 deletions
43
src/database/migrations/20221003130006-reviewer-creation.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,43 @@ | ||
/** @type {import('sequelize-cli').Migration} */ | ||
module.exports = { | ||
up: async (queryInterface, Sequelize) => { | ||
await queryInterface.createTable("reviewers", { | ||
request_id: { | ||
allowNull: false, | ||
primaryKey: true, | ||
type: Sequelize.BIGINT, | ||
references: { | ||
model: "review_requests", | ||
key: "id", | ||
}, | ||
onUpdate: "CASCADE", | ||
onDelete: "CASCADE", | ||
}, | ||
reviewer_id: { | ||
type: Sequelize.BIGINT, | ||
allowNull: false, | ||
primaryKey: true, | ||
references: { | ||
model: "users", | ||
key: "id", | ||
}, | ||
onUpdate: "CASCADE", | ||
onDelete: "CASCADE", | ||
}, | ||
created_at: { | ||
type: Sequelize.DATE, | ||
allowNull: false, | ||
defaultValue: Sequelize.fn("NOW"), | ||
}, | ||
updated_at: { | ||
type: Sequelize.DATE, | ||
allowNull: false, | ||
defaultValue: Sequelize.fn("NOW"), | ||
}, | ||
}) | ||
}, | ||
|
||
down: async (queryInterface) => { | ||
await queryInterface.dropTable("reviewers") | ||
}, | ||
} |
30 changes: 30 additions & 0 deletions
30
src/database/migrations/20221007124138-create-review-status.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,30 @@ | ||
module.exports = { | ||
up: async (queryInterface, Sequelize) => | ||
queryInterface.sequelize.transaction(async (t) => { | ||
await queryInterface.addColumn( | ||
"review_requests", // name of Source model | ||
"review_status", // name of column we're adding | ||
{ | ||
type: Sequelize.ENUM, | ||
values: ["OPEN", "MERGED", "CLOSED", "APPROVED"], | ||
allowNull: false, | ||
defaultValue: "OPEN", | ||
transaction: t, | ||
} | ||
) | ||
}), | ||
|
||
down: async (queryInterface, _) => | ||
queryInterface.sequelize.transaction(async (t) => { | ||
await queryInterface.removeColumn( | ||
"review_requests", // name of Source Model | ||
"review_status", // name of column we want to remove | ||
{ transaction: t } | ||
) | ||
// drop created enum | ||
await queryInterface.sequelize.query( | ||
"drop type enum_review_requests_review_status;", | ||
{ transaction: t } | ||
) | ||
}), | ||
} |
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