-
Notifications
You must be signed in to change notification settings - Fork 2
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 #31 from uwblueprint/S24/jerry/revert-roles-table
S24/jerry/revert roles table
- Loading branch information
Showing
15 changed files
with
163 additions
and
103 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
backend/typescript/migrations/2024.06.12T01.36.38.create-role-table.ts
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
55 changes: 55 additions & 0 deletions
55
backend/typescript/migrations/2024.07.26T02.18.24.removing-roles-table.ts
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,55 @@ | ||
import { DataType } from "sequelize-typescript"; | ||
|
||
import { Migration } from "../umzug"; | ||
|
||
export const up: Migration = async ({ context: sequelize }) => { | ||
await sequelize.getQueryInterface().removeColumn("users", "role_id"); | ||
await sequelize.getQueryInterface().addColumn("users", "role", { | ||
type: DataType.ENUM( | ||
"Administrator", | ||
"Animal Behaviourist", | ||
"Staff", | ||
"Volunteer", | ||
), | ||
allowNull: false, | ||
}); | ||
|
||
await sequelize.getQueryInterface().dropTable("roles"); | ||
}; | ||
|
||
export const down: Migration = async ({ context: sequelize }) => { | ||
await sequelize.getQueryInterface().createTable("roles", { | ||
id: { | ||
type: DataType.INTEGER, | ||
allowNull: false, | ||
primaryKey: true, | ||
autoIncrement: true, | ||
}, | ||
role_name: { | ||
type: DataType.STRING, | ||
allowNull: false, | ||
}, | ||
}); | ||
|
||
await sequelize | ||
.getQueryInterface() | ||
.bulkInsert("roles", [ | ||
{ role_name: "Administrator" }, | ||
{ role_name: "Animal Behaviourist" }, | ||
{ role_name: "Staff" }, | ||
{ role_name: "Volunteer" }, | ||
]); | ||
|
||
await sequelize.getQueryInterface().addColumn("users", "role_id", { | ||
type: DataType.INTEGER, | ||
allowNull: true, | ||
references: { | ||
model: "roles", | ||
key: "id", | ||
}, | ||
onUpdate: "CASCADE", | ||
onDelete: "SET NULL", | ||
}); | ||
|
||
await sequelize.getQueryInterface().removeColumn("users", "role"); | ||
}; |
14 changes: 14 additions & 0 deletions
14
backend/typescript/migrations/2024.07.27T17.21.42.add-status-to-user-table.ts
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,14 @@ | ||
import { DataType } from "sequelize-typescript"; | ||
import { Migration } from "../umzug"; | ||
|
||
export const up: Migration = async ({ context: sequelize }) => { | ||
await sequelize.getQueryInterface().addColumn("users", "status", { | ||
type: DataType.ENUM("Active", "Invited", "Inactive"), | ||
allowNull: false, | ||
}); | ||
}; | ||
|
||
export const down: Migration = async ({ context: sequelize }) => { | ||
await sequelize.getQueryInterface().removeColumn("users", "status"); | ||
await sequelize.query(`DROP TYPE IF EXISTS enum_users_status;`); | ||
}; |
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
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.