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

module.exports = {
  async up(queryInterface) {
    await queryInterface.createTable("true_false", {
      ID_TRUE_FALSE: {
        type: Sequelize.UUID,
        primaryKey: true,
        defaultValue: Sequelize.UUIDV4,
        allowNull: false,
      },
      ID_ADMIN_EXERCISE: {
        type: Sequelize.UUID,
        allowNull: false,
      },
      IS_TRUE: {
        type: Sequelize.TINYINT(1),
        allowNull: false,
      },
      TIME_TRUE_FALSE: {
        type: Sequelize.DATE,
        allowNull: true,
        defaultValue: Sequelize.NOW,
      },
    });

    await queryInterface.addConstraint("true_false", {
      fields: ["ID_ADMIN_EXERCISE"],
      type: "foreign key",
      name: "FK_TF_TERDAPAT",
      references: {
        table: "admin_exercise",
        field: "ID_ADMIN_EXERCISE",
      },
      onUpdate: "CASCADE",
      onDelete: "CASCADE",
    });
  },

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