const { v4: uuid } = require('uuid');

module.exports = {
  /**
   * @param{import("sequelize").QueryInterface} queryInterface
   * @return {Promise<void>}
   */
  async up(queryInterface) {
    const createdAt = new Date();
    const updatedAt = new Date();

    /** @type {Map<string, string>} */
    const idMap = new Map();

    /**
     * @param {string} key
     * @return {string}
     */
    function getId(key) {
      if (idMap.has(key)) {
        return idMap.get(key);
      }
      const id = uuid();
      idMap.set(key, id);
      return id;
    }

    await queryInterface.bulkInsert('roles', [
      {
        id: getId('SuperAdmin'),
        name: 'Super Administrator',
        createdAt,
        updatedAt,
      },

      {
        id: getId('Administrator'),
        name: 'Administrator',
        createdAt,
        updatedAt,
      },

      {
        id: getId('CooperativeManager'),
        name: 'Cooperative Manager',
        createdAt,
        updatedAt,
      },

      {
        id: getId('FinancialOfficer'),
        name: 'Financial Officer',
        createdAt,
        updatedAt,
      },

      {
        id: getId('ProjectCoordinator'),
        name: 'Project Coordinator',
        createdAt,
        updatedAt,
      },

      {
        id: getId('MemberRelationsSpecialist'),
        name: 'Member Relations Specialist',
        createdAt,
        updatedAt,
      },

      { id: getId('Visitor'), name: 'Visitor', createdAt, updatedAt },

      { id: getId('Public'), name: 'Public', createdAt, updatedAt },
    ]);

    /**
     * @param {string} name
     */
    function createPermissions(name) {
      return [
        {
          id: getId(`CREATE_${name.toUpperCase()}`),
          createdAt,
          updatedAt,
          name: `CREATE_${name.toUpperCase()}`,
        },
        {
          id: getId(`READ_${name.toUpperCase()}`),
          createdAt,
          updatedAt,
          name: `READ_${name.toUpperCase()}`,
        },
        {
          id: getId(`UPDATE_${name.toUpperCase()}`),
          createdAt,
          updatedAt,
          name: `UPDATE_${name.toUpperCase()}`,
        },
        {
          id: getId(`DELETE_${name.toUpperCase()}`),
          createdAt,
          updatedAt,
          name: `DELETE_${name.toUpperCase()}`,
        },
      ];
    }

    const entities = [
      'users',
      'accounts',
      'announcements',
      'barter_offers',
      'delayed_payments',
      'islamic_finance_library',
      'loan_applications',
      'partners',
      'projects',
      'transactions',
      'roles',
      'permissions',
      'kooperatif',
      ,
    ];
    await queryInterface.bulkInsert(
      'permissions',
      entities.flatMap(createPermissions),
    );
    await queryInterface.bulkInsert('permissions', [
      {
        id: getId(`READ_API_DOCS`),
        createdAt,
        updatedAt,
        name: `READ_API_DOCS`,
      },
    ]);
    await queryInterface.bulkInsert('permissions', [
      {
        id: getId(`CREATE_SEARCH`),
        createdAt,
        updatedAt,
        name: `CREATE_SEARCH`,
      },
    ]);

    await queryInterface.bulkUpdate(
      'roles',
      { globalAccess: true },
      { id: getId('SuperAdmin') },
    );

    await queryInterface.sequelize
      .query(`create table "rolesPermissionsPermissions"
(
"createdAt"           timestamp with time zone not null,
"updatedAt"           timestamp with time zone not null,
"roles_permissionsId" uuid                     not null,
"permissionId"        uuid                     not null,
primary key ("roles_permissionsId", "permissionId")
);`);

    await queryInterface.bulkInsert('rolesPermissionsPermissions', [
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('CREATE_ACCOUNTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('READ_ACCOUNTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('UPDATE_ACCOUNTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('DELETE_ACCOUNTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('CREATE_ACCOUNTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('READ_ACCOUNTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('UPDATE_ACCOUNTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('DELETE_ACCOUNTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('READ_ACCOUNTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('UPDATE_ACCOUNTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('READ_ACCOUNTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('UPDATE_ACCOUNTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('CREATE_ANNOUNCEMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('READ_ANNOUNCEMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('UPDATE_ANNOUNCEMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('DELETE_ANNOUNCEMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('READ_ANNOUNCEMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('UPDATE_ANNOUNCEMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('READ_ANNOUNCEMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('UPDATE_ANNOUNCEMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('READ_ANNOUNCEMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('UPDATE_ANNOUNCEMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Visitor'),
        permissionId: getId('READ_ANNOUNCEMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Visitor'),
        permissionId: getId('UPDATE_ANNOUNCEMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('CREATE_BARTER_OFFERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('READ_BARTER_OFFERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('UPDATE_BARTER_OFFERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('DELETE_BARTER_OFFERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('READ_BARTER_OFFERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('UPDATE_BARTER_OFFERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('READ_BARTER_OFFERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('UPDATE_BARTER_OFFERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('CREATE_BARTER_OFFERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('READ_BARTER_OFFERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('UPDATE_BARTER_OFFERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('DELETE_BARTER_OFFERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('CREATE_DELAYED_PAYMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('READ_DELAYED_PAYMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('UPDATE_DELAYED_PAYMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('DELETE_DELAYED_PAYMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('CREATE_DELAYED_PAYMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('READ_DELAYED_PAYMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('UPDATE_DELAYED_PAYMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('DELETE_DELAYED_PAYMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('READ_DELAYED_PAYMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('UPDATE_DELAYED_PAYMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('READ_DELAYED_PAYMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('UPDATE_DELAYED_PAYMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('CREATE_ISLAMIC_FINANCE_LIBRARY'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('READ_ISLAMIC_FINANCE_LIBRARY'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('UPDATE_ISLAMIC_FINANCE_LIBRARY'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('DELETE_ISLAMIC_FINANCE_LIBRARY'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('READ_ISLAMIC_FINANCE_LIBRARY'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('UPDATE_ISLAMIC_FINANCE_LIBRARY'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('READ_ISLAMIC_FINANCE_LIBRARY'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('UPDATE_ISLAMIC_FINANCE_LIBRARY'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('READ_ISLAMIC_FINANCE_LIBRARY'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('UPDATE_ISLAMIC_FINANCE_LIBRARY'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Visitor'),
        permissionId: getId('READ_ISLAMIC_FINANCE_LIBRARY'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Visitor'),
        permissionId: getId('UPDATE_ISLAMIC_FINANCE_LIBRARY'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('CREATE_LOAN_APPLICATIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('READ_LOAN_APPLICATIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('UPDATE_LOAN_APPLICATIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('DELETE_LOAN_APPLICATIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('CREATE_LOAN_APPLICATIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('READ_LOAN_APPLICATIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('UPDATE_LOAN_APPLICATIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('DELETE_LOAN_APPLICATIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('READ_LOAN_APPLICATIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('UPDATE_LOAN_APPLICATIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('READ_LOAN_APPLICATIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('UPDATE_LOAN_APPLICATIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('CREATE_PARTNERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('READ_PARTNERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('UPDATE_PARTNERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('DELETE_PARTNERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('READ_PARTNERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('UPDATE_PARTNERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('DELETE_PARTNERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('READ_PARTNERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('UPDATE_PARTNERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('READ_PARTNERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('UPDATE_PARTNERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('CREATE_PROJECTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('READ_PROJECTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('UPDATE_PROJECTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('DELETE_PROJECTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('READ_PROJECTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('UPDATE_PROJECTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('CREATE_PROJECTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('READ_PROJECTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('UPDATE_PROJECTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('DELETE_PROJECTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('READ_PROJECTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('UPDATE_PROJECTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('CREATE_TRANSACTIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('READ_TRANSACTIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('UPDATE_TRANSACTIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('DELETE_TRANSACTIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('CREATE_TRANSACTIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('READ_TRANSACTIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('UPDATE_TRANSACTIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('DELETE_TRANSACTIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('READ_TRANSACTIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('UPDATE_TRANSACTIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('READ_TRANSACTIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('UPDATE_TRANSACTIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('CooperativeManager'),
        permissionId: getId('CREATE_SEARCH'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('FinancialOfficer'),
        permissionId: getId('CREATE_SEARCH'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('ProjectCoordinator'),
        permissionId: getId('CREATE_SEARCH'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('MemberRelationsSpecialist'),
        permissionId: getId('CREATE_SEARCH'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Visitor'),
        permissionId: getId('CREATE_SEARCH'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('CREATE_USERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('READ_USERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('UPDATE_USERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('DELETE_USERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('CREATE_ACCOUNTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('READ_ACCOUNTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('UPDATE_ACCOUNTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('DELETE_ACCOUNTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('CREATE_ANNOUNCEMENTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('READ_ANNOUNCEMENTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('UPDATE_ANNOUNCEMENTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('DELETE_ANNOUNCEMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('CREATE_BARTER_OFFERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('READ_BARTER_OFFERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('UPDATE_BARTER_OFFERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('DELETE_BARTER_OFFERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('CREATE_DELAYED_PAYMENTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('READ_DELAYED_PAYMENTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('UPDATE_DELAYED_PAYMENTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('DELETE_DELAYED_PAYMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('CREATE_ISLAMIC_FINANCE_LIBRARY'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('READ_ISLAMIC_FINANCE_LIBRARY'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('UPDATE_ISLAMIC_FINANCE_LIBRARY'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('DELETE_ISLAMIC_FINANCE_LIBRARY'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('CREATE_LOAN_APPLICATIONS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('READ_LOAN_APPLICATIONS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('UPDATE_LOAN_APPLICATIONS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('DELETE_LOAN_APPLICATIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('CREATE_PARTNERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('READ_PARTNERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('UPDATE_PARTNERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('DELETE_PARTNERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('CREATE_PROJECTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('READ_PROJECTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('UPDATE_PROJECTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('DELETE_PROJECTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('CREATE_TRANSACTIONS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('READ_TRANSACTIONS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('UPDATE_TRANSACTIONS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('DELETE_TRANSACTIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('CREATE_USERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('READ_USERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('UPDATE_USERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('DELETE_USERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('CREATE_ACCOUNTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('READ_ACCOUNTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('UPDATE_ACCOUNTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('DELETE_ACCOUNTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('CREATE_ANNOUNCEMENTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('READ_ANNOUNCEMENTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('UPDATE_ANNOUNCEMENTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('DELETE_ANNOUNCEMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('CREATE_BARTER_OFFERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('READ_BARTER_OFFERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('UPDATE_BARTER_OFFERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('DELETE_BARTER_OFFERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('CREATE_DELAYED_PAYMENTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('READ_DELAYED_PAYMENTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('UPDATE_DELAYED_PAYMENTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('DELETE_DELAYED_PAYMENTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('CREATE_ISLAMIC_FINANCE_LIBRARY'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('READ_ISLAMIC_FINANCE_LIBRARY'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('UPDATE_ISLAMIC_FINANCE_LIBRARY'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('DELETE_ISLAMIC_FINANCE_LIBRARY'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('CREATE_LOAN_APPLICATIONS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('READ_LOAN_APPLICATIONS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('UPDATE_LOAN_APPLICATIONS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('DELETE_LOAN_APPLICATIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('CREATE_PARTNERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('READ_PARTNERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('UPDATE_PARTNERS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('DELETE_PARTNERS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('CREATE_PROJECTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('READ_PROJECTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('UPDATE_PROJECTS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('DELETE_PROJECTS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('CREATE_TRANSACTIONS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('READ_TRANSACTIONS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('UPDATE_TRANSACTIONS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('DELETE_TRANSACTIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('CREATE_ROLES'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('READ_ROLES'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('UPDATE_ROLES'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('DELETE_ROLES'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('CREATE_PERMISSIONS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('READ_PERMISSIONS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('UPDATE_PERMISSIONS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('DELETE_PERMISSIONS'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('CREATE_KOOPERATIF'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('READ_KOOPERATIF'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('UPDATE_KOOPERATIF'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('DELETE_KOOPERATIF'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('READ_API_DOCS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('SuperAdmin'),
        permissionId: getId('CREATE_SEARCH'),
      },

      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('READ_API_DOCS'),
      },
      {
        createdAt,
        updatedAt,
        roles_permissionsId: getId('Administrator'),
        permissionId: getId('CREATE_SEARCH'),
      },
    ]);

    await queryInterface.sequelize.query(
      `UPDATE "users" SET "app_roleId"='${getId(
        'SuperAdmin',
      )}' WHERE "email"='super_admin@flatlogic.com'`,
    );
    await queryInterface.sequelize.query(
      `UPDATE "users" SET "app_roleId"='${getId(
        'Administrator',
      )}' WHERE "email"='admin@flatlogic.com'`,
    );

    await queryInterface.sequelize.query(
      `UPDATE "users" SET "app_roleId"='${getId(
        'CooperativeManager',
      )}' WHERE "email"='client@hello.com'`,
    );
    await queryInterface.sequelize.query(
      `UPDATE "users" SET "app_roleId"='${getId(
        'FinancialOfficer',
      )}' WHERE "email"='john@doe.com'`,
    );
  },
};
