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(
        'accounts',
        {
          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(
        'announcements',
        {
          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(
        'barter_offers',
        {
          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(
        'delayed_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(
        'islamic_finance_library',
        {
          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(
        'loan_applications',
        {
          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(
        'partners',
        {
          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(
        'transactions',
        {
          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(
        'kooperatif',
        {
          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(
        'accounts',
        'partnerId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

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

      await queryInterface.addColumn(
        'accounts',
        'account_type',
        {
          type: Sequelize.DataTypes.ENUM,

          values: [
            'Karz-ıHasen',
            'KatılımHesabı',
            'TL',
            'EURO',
            'DOLAR',
            'ALTIN',
            'KatılımEmeklilikHesabı',
          ],
        },
        { transaction },
      );

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

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

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

      await queryInterface.addColumn(
        'barter_offers',
        'partnerId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

      await queryInterface.addColumn(
        'delayed_payments',
        'partnerId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

      await queryInterface.addColumn(
        'delayed_payments',
        'notified',
        {
          type: Sequelize.DataTypes.BOOLEAN,

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

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

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

      await queryInterface.addColumn(
        'islamic_finance_library',
        'resource_type',
        {
          type: Sequelize.DataTypes.ENUM,

          values: ['Article', 'Book', 'Resource'],
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'loan_applications',
        'partnerId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

      await queryInterface.addColumn(
        'loan_applications',
        'loan_type',
        {
          type: Sequelize.DataTypes.ENUM,

          values: [
            'CariGiderler',
            'YatırımGiderleri',
            'MalAlımı',
            'KrediliAlışVeriş',
            'TeminatMektubu',
          ],
        },
        { transaction },
      );

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

      await queryInterface.addColumn(
        'loan_applications',
        'approved',
        {
          type: Sequelize.DataTypes.BOOLEAN,

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

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

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

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

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

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

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

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

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

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

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

      await queryInterface.addColumn(
        'projects',
        'description',
        {
          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(
        'transactions',
        'accountId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

      await queryInterface.addColumn(
        'transactions',
        'transaction_type',
        {
          type: Sequelize.DataTypes.ENUM,

          values: ['Deposit', 'Withdrawal', 'Payment'],
        },
        { 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(
        'kooperatif',
        'name',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

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

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

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

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

      await queryInterface.addColumn(
        'accounts',
        'kooperatifId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'announcements',
        'kooperatifId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'barter_offers',
        'kooperatifId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'delayed_payments',
        'kooperatifId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'islamic_finance_library',
        'kooperatifId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'loan_applications',
        'kooperatifId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'partners',
        'kooperatifId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

      await queryInterface.addColumn(
        'transactions',
        'kooperatifId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'kooperatif',
            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('transactions', 'kooperatifId', {
        transaction,
      });

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

      await queryInterface.removeColumn('partners', 'kooperatifId', {
        transaction,
      });

      await queryInterface.removeColumn('loan_applications', 'kooperatifId', {
        transaction,
      });

      await queryInterface.removeColumn(
        'islamic_finance_library',
        'kooperatifId',
        { transaction },
      );

      await queryInterface.removeColumn('delayed_payments', 'kooperatifId', {
        transaction,
      });

      await queryInterface.removeColumn('barter_offers', 'kooperatifId', {
        transaction,
      });

      await queryInterface.removeColumn('announcements', 'kooperatifId', {
        transaction,
      });

      await queryInterface.removeColumn('accounts', 'kooperatifId', {
        transaction,
      });

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

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

      await queryInterface.removeColumn('kooperatif', '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('transactions', 'transaction_type', {
        transaction,
      });

      await queryInterface.removeColumn('transactions', 'transaction_date', {
        transaction,
      });

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

      await queryInterface.removeColumn('transactions', 'accountId', {
        transaction,
      });

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

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

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

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

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

      await queryInterface.removeColumn('partners', 'registration_date', {
        transaction,
      });

      await queryInterface.removeColumn('partners', 'sector', { transaction });

      await queryInterface.removeColumn('partners', 'phone', { transaction });

      await queryInterface.removeColumn('partners', 'insurance_number', {
        transaction,
      });

      await queryInterface.removeColumn('partners', 'tax_number', {
        transaction,
      });

      await queryInterface.removeColumn('partners', 'tc_number', {
        transaction,
      });

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

      await queryInterface.removeColumn('loan_applications', 'approved', {
        transaction,
      });

      await queryInterface.removeColumn(
        'loan_applications',
        'application_date',
        { transaction },
      );

      await queryInterface.removeColumn('loan_applications', 'loan_type', {
        transaction,
      });

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

      await queryInterface.removeColumn('loan_applications', 'partnerId', {
        transaction,
      });

      await queryInterface.removeColumn(
        'islamic_finance_library',
        'resource_type',
        { transaction },
      );

      await queryInterface.removeColumn('islamic_finance_library', 'content', {
        transaction,
      });

      await queryInterface.removeColumn('islamic_finance_library', 'title', {
        transaction,
      });

      await queryInterface.removeColumn('delayed_payments', 'notified', {
        transaction,
      });

      await queryInterface.removeColumn('delayed_payments', 'due_date', {
        transaction,
      });

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

      await queryInterface.removeColumn('delayed_payments', 'partnerId', {
        transaction,
      });

      await queryInterface.removeColumn('barter_offers', 'offer_date', {
        transaction,
      });

      await queryInterface.removeColumn('barter_offers', 'offer_details', {
        transaction,
      });

      await queryInterface.removeColumn('barter_offers', 'partnerId', {
        transaction,
      });

      await queryInterface.removeColumn('announcements', 'published_date', {
        transaction,
      });

      await queryInterface.removeColumn('announcements', 'content', {
        transaction,
      });

      await queryInterface.removeColumn('announcements', 'title', {
        transaction,
      });

      await queryInterface.removeColumn('accounts', 'account_type', {
        transaction,
      });

      await queryInterface.removeColumn('accounts', 'current_debt', {
        transaction,
      });

      await queryInterface.removeColumn('accounts', 'debt_limit', {
        transaction,
      });

      await queryInterface.removeColumn('accounts', 'balance', { transaction });

      await queryInterface.removeColumn('accounts', 'partnerId', {
        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('kooperatif', { transaction });

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

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

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

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

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

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

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

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

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

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

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

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

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