const { Sequelize } = require("sequelize");

module.exports = {
  async up(queryInterface) {
    await queryInterface.createTable("report", {
      ID_REPORT: {
        type: Sequelize.UUID,
        primaryKey: true,
        defaultValue: Sequelize.UUIDV4,
        allowNull: false,
      },
      ID: {
        type: Sequelize.UUID,
        allowNull: false,
      },
      REPORTS: {
        type: Sequelize.TEXT,
        allowNull: false,
      },
      TIME_REPORT: {
        type: Sequelize.DATE,
        allowNull: true,
        defaultValue: Sequelize.NOW,
      },
    });

    await queryInterface.addConstraint("report", {
      fields: ["ID"],
      type: "foreign key",
      name: "FK_MELAPORKAN",
      references: {
        table: "users",
        field: "ID",
      },
      onUpdate: "CASCADE",
      onDelete: "CASCADE",
    });
  },

  async down(queryInterface) {
    await queryInterface.dropTable("report");
  },
};
