const { defaultKeys, migrationDefaults, relationShip } = require('../sequelize/defaults');
/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    await queryInterface.createTable('credintials', {
      ...defaultKeys("credintial_id"),
      username: {
        type: Sequelize.STRING,
        unique: true,
        allowNull: false,
      },
      password_hash: {
        type: Sequelize.STRING,
        allowNull: false,
      },
      user_id: relationShip({
        modelName: "users",
        key: "user_id",
        unique: true,
      }),
      ...migrationDefaults({ withUser: false, paranoid: false }),
    });
  },
  async down(queryInterface, Sequelize) {
    await queryInterface.dropTable('credintials');
  }
};