"use strict";

/** @type {import('sequelize-cli').Migration} */
module.exports = {
	async up(queryInterface, Sequelize) {
		// Add granular permission columns to rolemenus (defaults align with Permission model)
		await queryInterface.addColumn("rolemenus", "can_create", {
			type: Sequelize.BOOLEAN,
			allowNull: false,
			defaultValue: false,
		});

		await queryInterface.addColumn("rolemenus", "can_read", {
			type: Sequelize.BOOLEAN,
			allowNull: false,
			defaultValue: true,
		});

		await queryInterface.addColumn("rolemenus", "can_update", {
			type: Sequelize.BOOLEAN,
			allowNull: false,
			defaultValue: false,
		});

		await queryInterface.addColumn("rolemenus", "can_delete", {
			type: Sequelize.BOOLEAN,
			allowNull: false,
			defaultValue: false,
		});
	},

	async down(queryInterface, Sequelize) {
		await queryInterface.removeColumn("rolemenus", "can_delete");
		await queryInterface.removeColumn("rolemenus", "can_update");
		await queryInterface.removeColumn("rolemenus", "can_read");
		await queryInterface.removeColumn("rolemenus", "can_create");
	},
};
