"use strict";

module.exports = {
  up: async (queryInterface, Sequelize) => {
    await queryInterface.changeColumn("Messages", "content", {
      type: Sequelize.TEXT,
      allowNull: true,
    });
  },

  down: async (queryInterface, Sequelize) => {
    // First update any null content to empty string before reverting
    await queryInterface.sequelize.query(
      `UPDATE "Messages" SET content = '' WHERE content IS NULL`
    );
    await queryInterface.changeColumn("Messages", "content", {
      type: Sequelize.TEXT,
      allowNull: false,
    });
  },
};
