module.exports = {
  /**
   * @param {QueryInterface} queryInterface
   * @param {Sequelize} Sequelize
   * @returns {Promise<void>}
   */
  async up(queryInterface, Sequelize) {
    /**
     * @type {Transaction}
     */
    const transaction = await queryInterface.sequelize.transaction();
    try {
      await queryInterface.createTable(
        'users',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'assets',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'employees',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'financial_records',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'inventories',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'manufacturing_orders',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'procurements',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'projects',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'sales',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'subscriptions',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'roles',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'permissions',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'companies',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'invoices',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'payments',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'contracts',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'shipments',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'warehouses',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'payrolls',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'attendance',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'leave_requests',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'recruitment',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'budgets',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'taxes',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'expenses',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'revenues',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'leads',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'tickets',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'marketing_campaigns',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'audit_logs',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'notifications',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'users',
        'firstName',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'users',
        'lastName',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'users',
        'phoneNumber',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'users',
        'email',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'users',
        'disabled',
        {
          type: Sequelize.DataTypes.BOOLEAN,

          defaultValue: false,
          allowNull: false,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'users',
        'password',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'users',
        'emailVerified',
        {
          type: Sequelize.DataTypes.BOOLEAN,

          defaultValue: false,
          allowNull: false,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'users',
        'emailVerificationToken',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'users',
        'emailVerificationTokenExpiresAt',
        {
          type: Sequelize.DataTypes.DATE,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'users',
        'passwordResetToken',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'users',
        'passwordResetTokenExpiresAt',
        {
          type: Sequelize.DataTypes.DATE,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'users',
        'provider',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'assets',
        'asset_name',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'assets',
        'value',
        {
          type: Sequelize.DataTypes.DECIMAL,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'assets',
        'companyId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'employees',
        'full_name',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'employees',
        'companyId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'financial_records',
        'record_type',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'financial_records',
        'amount',
        {
          type: Sequelize.DataTypes.DECIMAL,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'financial_records',
        'date',
        {
          type: Sequelize.DataTypes.DATE,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'financial_records',
        'companyId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'inventories',
        'item_name',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'inventories',
        'quantity',
        {
          type: Sequelize.DataTypes.INTEGER,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'inventories',
        'companyId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'manufacturing_orders',
        'order_name',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'manufacturing_orders',
        'scheduled_date',
        {
          type: Sequelize.DataTypes.DATE,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'manufacturing_orders',
        'companyId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'procurements',
        'request_name',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'procurements',
        'approval_status',
        {
          type: Sequelize.DataTypes.ENUM,

          values: ['Pending', 'Approved', 'Rejected'],
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'procurements',
        'companyId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'projects',
        'project_name',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'projects',
        'start_date',
        {
          type: Sequelize.DataTypes.DATE,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'projects',
        'end_date',
        {
          type: Sequelize.DataTypes.DATE,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'projects',
        'companyId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'sales',
        'lead_name',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'sales',
        'status',
        {
          type: Sequelize.DataTypes.ENUM,

          values: ['New', 'InProgress', 'Closed'],
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'sales',
        'companyId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'subscriptions',
        'subscription_name',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'subscriptions',
        'renewal_date',
        {
          type: Sequelize.DataTypes.DATE,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'subscriptions',
        'companyId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'permissions',
        'name',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'roles',
        'name',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'roles',
        'role_customization',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'users',
        'app_roleId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'roles',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'companies',
        'name',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'roles',
        'globalAccess',
        {
          type: Sequelize.DataTypes.BOOLEAN,

          defaultValue: false,
          allowNull: false,
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'users',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'assets',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'employees',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'financial_records',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'inventories',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'manufacturing_orders',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'procurements',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'projects',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'sales',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'subscriptions',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'invoices',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'payments',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'contracts',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'shipments',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'warehouses',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'payrolls',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'attendance',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'leave_requests',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'recruitment',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'budgets',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'taxes',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'expenses',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'revenues',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'leads',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'tickets',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'marketing_campaigns',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'audit_logs',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'notifications',
        'companiesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'companies',
            key: 'id',
          },
        },
        { transaction },
      );

      await transaction.commit();
    } catch (err) {
      await transaction.rollback();
      throw err;
    }
  },
  /**
   * @param {QueryInterface} queryInterface
   * @param {Sequelize} Sequelize
   * @returns {Promise<void>}
   */
  async down(queryInterface, Sequelize) {
    /**
     * @type {Transaction}
     */
    const transaction = await queryInterface.sequelize.transaction();
    try {
      await queryInterface.removeColumn('notifications', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('audit_logs', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('marketing_campaigns', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('tickets', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('leads', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('revenues', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('expenses', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('taxes', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('budgets', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('recruitment', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('leave_requests', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('attendance', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('payrolls', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('warehouses', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('shipments', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('contracts', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('payments', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('invoices', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('subscriptions', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('sales', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('projects', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('procurements', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('manufacturing_orders', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('inventories', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('financial_records', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('employees', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('assets', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('users', 'companiesId', {
        transaction,
      });

      await queryInterface.removeColumn('roles', 'globalAccess', {
        transaction,
      });

      await queryInterface.removeColumn('companies', 'name', { transaction });

      await queryInterface.removeColumn('users', 'app_roleId', { transaction });

      await queryInterface.removeColumn('roles', 'role_customization', {
        transaction,
      });

      await queryInterface.removeColumn('roles', 'name', { transaction });

      await queryInterface.removeColumn('permissions', 'name', { transaction });

      await queryInterface.removeColumn('subscriptions', 'companyId', {
        transaction,
      });

      await queryInterface.removeColumn('subscriptions', 'renewal_date', {
        transaction,
      });

      await queryInterface.removeColumn('subscriptions', 'subscription_name', {
        transaction,
      });

      await queryInterface.removeColumn('sales', 'companyId', { transaction });

      await queryInterface.removeColumn('sales', 'status', { transaction });

      await queryInterface.removeColumn('sales', 'lead_name', { transaction });

      await queryInterface.removeColumn('projects', 'companyId', {
        transaction,
      });

      await queryInterface.removeColumn('projects', 'end_date', {
        transaction,
      });

      await queryInterface.removeColumn('projects', 'start_date', {
        transaction,
      });

      await queryInterface.removeColumn('projects', 'project_name', {
        transaction,
      });

      await queryInterface.removeColumn('procurements', 'companyId', {
        transaction,
      });

      await queryInterface.removeColumn('procurements', 'approval_status', {
        transaction,
      });

      await queryInterface.removeColumn('procurements', 'request_name', {
        transaction,
      });

      await queryInterface.removeColumn('manufacturing_orders', 'companyId', {
        transaction,
      });

      await queryInterface.removeColumn(
        'manufacturing_orders',
        'scheduled_date',
        { transaction },
      );

      await queryInterface.removeColumn('manufacturing_orders', 'order_name', {
        transaction,
      });

      await queryInterface.removeColumn('inventories', 'companyId', {
        transaction,
      });

      await queryInterface.removeColumn('inventories', 'quantity', {
        transaction,
      });

      await queryInterface.removeColumn('inventories', 'item_name', {
        transaction,
      });

      await queryInterface.removeColumn('financial_records', 'companyId', {
        transaction,
      });

      await queryInterface.removeColumn('financial_records', 'date', {
        transaction,
      });

      await queryInterface.removeColumn('financial_records', 'amount', {
        transaction,
      });

      await queryInterface.removeColumn('financial_records', 'record_type', {
        transaction,
      });

      await queryInterface.removeColumn('employees', 'companyId', {
        transaction,
      });

      await queryInterface.removeColumn('employees', 'full_name', {
        transaction,
      });

      await queryInterface.removeColumn('assets', 'companyId', { transaction });

      await queryInterface.removeColumn('assets', 'value', { transaction });

      await queryInterface.removeColumn('assets', 'asset_name', {
        transaction,
      });

      await queryInterface.removeColumn('users', 'provider', { transaction });

      await queryInterface.removeColumn(
        'users',
        'passwordResetTokenExpiresAt',
        { transaction },
      );

      await queryInterface.removeColumn('users', 'passwordResetToken', {
        transaction,
      });

      await queryInterface.removeColumn(
        'users',
        'emailVerificationTokenExpiresAt',
        { transaction },
      );

      await queryInterface.removeColumn('users', 'emailVerificationToken', {
        transaction,
      });

      await queryInterface.removeColumn('users', 'emailVerified', {
        transaction,
      });

      await queryInterface.removeColumn('users', 'password', { transaction });

      await queryInterface.removeColumn('users', 'disabled', { transaction });

      await queryInterface.removeColumn('users', 'email', { transaction });

      await queryInterface.removeColumn('users', 'phoneNumber', {
        transaction,
      });

      await queryInterface.removeColumn('users', 'lastName', { transaction });

      await queryInterface.removeColumn('users', 'firstName', { transaction });

      await queryInterface.dropTable('notifications', { transaction });

      await queryInterface.dropTable('audit_logs', { transaction });

      await queryInterface.dropTable('marketing_campaigns', { transaction });

      await queryInterface.dropTable('tickets', { transaction });

      await queryInterface.dropTable('leads', { transaction });

      await queryInterface.dropTable('revenues', { transaction });

      await queryInterface.dropTable('expenses', { transaction });

      await queryInterface.dropTable('taxes', { transaction });

      await queryInterface.dropTable('budgets', { transaction });

      await queryInterface.dropTable('recruitment', { transaction });

      await queryInterface.dropTable('leave_requests', { transaction });

      await queryInterface.dropTable('attendance', { transaction });

      await queryInterface.dropTable('payrolls', { transaction });

      await queryInterface.dropTable('warehouses', { transaction });

      await queryInterface.dropTable('shipments', { transaction });

      await queryInterface.dropTable('contracts', { transaction });

      await queryInterface.dropTable('payments', { transaction });

      await queryInterface.dropTable('invoices', { transaction });

      await queryInterface.dropTable('companies', { transaction });

      await queryInterface.dropTable('permissions', { transaction });

      await queryInterface.dropTable('roles', { transaction });

      await queryInterface.dropTable('subscriptions', { transaction });

      await queryInterface.dropTable('sales', { transaction });

      await queryInterface.dropTable('projects', { transaction });

      await queryInterface.dropTable('procurements', { transaction });

      await queryInterface.dropTable('manufacturing_orders', { transaction });

      await queryInterface.dropTable('inventories', { transaction });

      await queryInterface.dropTable('financial_records', { transaction });

      await queryInterface.dropTable('employees', { transaction });

      await queryInterface.dropTable('assets', { transaction });

      await queryInterface.dropTable('users', { transaction });

      await transaction.commit();
    } catch (err) {
      await transaction.rollback();
      throw err;
    }
  },
};
