ability to ban and unban users
This commit is contained in:
41
backend/migrations/20260106000001-add-user-ban-fields.js
Normal file
41
backend/migrations/20260106000001-add-user-ban-fields.js
Normal file
@@ -0,0 +1,41 @@
|
||||
"use strict";
|
||||
|
||||
module.exports = {
|
||||
up: async (queryInterface, Sequelize) => {
|
||||
// isBanned - boolean flag indicating if user is banned
|
||||
await queryInterface.addColumn("Users", "isBanned", {
|
||||
type: Sequelize.BOOLEAN,
|
||||
defaultValue: false,
|
||||
allowNull: false,
|
||||
});
|
||||
|
||||
// bannedAt - timestamp when ban was applied
|
||||
await queryInterface.addColumn("Users", "bannedAt", {
|
||||
type: Sequelize.DATE,
|
||||
allowNull: true,
|
||||
});
|
||||
|
||||
// bannedBy - UUID of admin who applied the ban
|
||||
await queryInterface.addColumn("Users", "bannedBy", {
|
||||
type: Sequelize.UUID,
|
||||
allowNull: true,
|
||||
references: {
|
||||
model: "Users",
|
||||
key: "id",
|
||||
},
|
||||
});
|
||||
|
||||
// banReason - reason provided by admin for the ban
|
||||
await queryInterface.addColumn("Users", "banReason", {
|
||||
type: Sequelize.TEXT,
|
||||
allowNull: true,
|
||||
});
|
||||
},
|
||||
|
||||
down: async (queryInterface, Sequelize) => {
|
||||
await queryInterface.removeColumn("Users", "banReason");
|
||||
await queryInterface.removeColumn("Users", "bannedBy");
|
||||
await queryInterface.removeColumn("Users", "bannedAt");
|
||||
await queryInterface.removeColumn("Users", "isBanned");
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user