'use strict';
const bcrypt = require('bcrypt');
const { faker } = require('@faker-js/faker');
const { User, Credintial } = require('../models');

/** @type {import('sequelize-cli').Migration} */
module.exports = {
  async up(queryInterface, Sequelize) {
    try {
      await User.bulkCreate([
        {
          role: "SuperAdmin",
          fullname: "Admin",
          branch_id: "b1235006-4f8d-421b-9e16-56bb973800f6",
          mobile: "123456789",
          status: true,
          credintial: {
            username: 'admin',
            password: '12345678',
          },
        },
        {
          role: "Admin",
          fullname: "Admin-A",
          branch_id: "5b1649ab-cc07-45f3-8cde-df69769baf48",
          mobile: "987654321",
          status: true,
          credintial: {
            username: 'a@admin',
            password: '12345678',
          },
        },
        {
          role: "Admin",
          fullname: "Admin-B",
          branch_id: "45ced70a-b4bf-43e5-bc90-93ba8db98fce",
          mobile: "987654321",
          status: true,
          credintial: {
            username: 'b@admin',
            password: '12345678',
          },
        },
        {
          role: "Admin",
          fullname: "Admin-C",
          branch_id: "f6496f62-6098-4f12-a176-7a4f58e71a31",
          mobile: "987654321",
          status: true,
          credintial: {
            username: 'c@admin',
            password: '12345678',
          },
        },
        {
          role: "Admin",
          fullname: "Admin-D",
          branch_id: "9c390431-887d-4d9d-82d1-ca92d1718bb9",
          mobile: "987654321",
          status: true,
          credintial: {
            username: 'd@admin',
            password: '12345678',
          },
        },
      ], {
        include: [
          {
            model: Credintial,
            as: 'credintial',
          },
        ]
      });
    } catch (error) {
      console.error(error);
    }
  },

  async down(queryInterface, Sequelize) {
    await queryInterface.bulkDelete('users', null, {});
    await queryInterface.bulkDelete('credintials', null, {});
  }
};
