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(
        'claims',
        {
          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(
        'clients',
        {
          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(
        'company_profiles',
        {
          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(
        'drivers',
        {
          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(
        'guarantees',
        {
          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(
        'infractions',
        {
          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_saas',
        {
          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(
        'maintenance',
        {
          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(
        'plans',
        {
          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(
        'reservations',
        {
          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(
        'tenants',
        {
          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(
        'vehicle_conditions',
        {
          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(
        'vehicles',
        {
          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(
        'agences',
        {
          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(
        'claims',
        'tenantId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'claims',
        'clientId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'claims',
        'reservationId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

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

          values: ['ouverte', 'en_cours', 'resolue'],
        },
        { transaction },
      );

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

      await queryInterface.addColumn(
        'clients',
        'tenantId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

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

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

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

      await queryInterface.addColumn(
        'clients',
        'id_type',
        {
          type: Sequelize.DataTypes.ENUM,

          values: ['CIN', 'Passeport'],
        },
        { transaction },
      );

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

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

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

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

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

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

      await queryInterface.addColumn(
        'company_profiles',
        'tenantId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

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

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

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

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

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

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

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

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

      await queryInterface.addColumn(
        'drivers',
        'tenantId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'drivers',
        'reservationId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

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

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

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

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

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

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

          values: ['depense', 'revenu'],
        },
        { transaction },
      );

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

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

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

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

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

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

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

      await queryInterface.addColumn(
        'guarantees',
        'tenantId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'guarantees',
        'reservationId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'guarantees',
        'method',
        {
          type: Sequelize.DataTypes.ENUM,

          values: ['especes', 'carte_bloquee', 'cheque'],
        },
        { transaction },
      );

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

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

          values: ['retenue', 'restituee', 'partielle'],
        },
        { transaction },
      );

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

      await queryInterface.addColumn(
        'infractions',
        'tenantId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'infractions',
        'vehicleId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'infractions',
        'reservationId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

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

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

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

          values: ['ouverte', 'payee', 'conteste'],
        },
        { transaction },
      );

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

      await queryInterface.addColumn(
        'invoices_saas',
        'tenantId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'invoices_saas',
        'subscriptionId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

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

          values: ['draft', 'sent', 'paid', 'void'],
        },
        { transaction },
      );

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

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

      await queryInterface.addColumn(
        'maintenance',
        'tenantId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'maintenance',
        'vehicleId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

          values: ['preventive', 'corrective'],
        },
        { transaction },
      );

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

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

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

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

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

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

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

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

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

      await queryInterface.addColumn(
        'payments',
        'method',
        {
          type: Sequelize.DataTypes.ENUM,

          values: ['especes', 'carte', 'virement', 'cheque'],
        },
        { transaction },
      );

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

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

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

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

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

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

      await queryInterface.addColumn(
        'plans',
        'period',
        {
          type: Sequelize.DataTypes.ENUM,

          values: ['monthly', 'yearly', 'both'],
        },
        { transaction },
      );

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

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

      await queryInterface.addColumn(
        'reservations',
        'tenantId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

      await queryInterface.addColumn(
        'reservations',
        'status_manual',
        {
          type: Sequelize.DataTypes.ENUM,

          values: ['en_attente', 'confirmee', 'annulee'],
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'reservations',
        'status_computed',
        {
          type: Sequelize.DataTypes.ENUM,

          values: [
            'a_venir',
            'en_cours',
            'a_restituer',
            'en_retard',
            'terminee',
            'annulee',
            'no_show',
          ],
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'reservations',
        'clientId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'reservations',
        'vehicleId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

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

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

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

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

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

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

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

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

      await queryInterface.addColumn(
        'reservations',
        'guarantee_method',
        {
          type: Sequelize.DataTypes.ENUM,

          values: ['especes', 'carte_bloquee', 'cheque', 'aucune'],
        },
        { transaction },
      );

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

      await queryInterface.addColumn(
        'reservations',
        'guarantee_status',
        {
          type: Sequelize.DataTypes.ENUM,

          values: ['retenue', 'restituee', 'partielle', 'non_applicable'],
        },
        { transaction },
      );

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

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

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

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

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

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

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

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

          values: ['active', 'past_due', 'canceled', 'trialing'],
        },
        { transaction },
      );

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

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

      await queryInterface.addColumn(
        'subscriptions',
        'payment_provider',
        {
          type: Sequelize.DataTypes.ENUM,

          values: ['stripe', 'manual', 'none'],
        },
        { transaction },
      );

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

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

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

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

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

          values: ['active', 'suspended', 'trial'],
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'tenants',
        'planId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

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

      await queryInterface.addColumn(
        'vehicle_conditions',
        'tenantId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'vehicle_conditions',
        'reservationId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

      await queryInterface.addColumn(
        'vehicles',
        'tenantId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

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

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

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

      await queryInterface.addColumn(
        'vehicles',
        'category',
        {
          type: Sequelize.DataTypes.ENUM,

          values: ['citadine', 'berline', 'SUV', 'utilitaire', 'luxe'],
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'vehicles',
        'fuel_type',
        {
          type: Sequelize.DataTypes.ENUM,

          values: ['essence', 'diesel', 'hybride', 'electrique'],
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'vehicles',
        'transmission',
        {
          type: Sequelize.DataTypes.ENUM,

          values: ['manuelle', 'automatique'],
        },
        { transaction },
      );

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

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

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

          values: ['disponible', 'reserve', 'en_location', 'hors_service'],
        },
        { transaction },
      );

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

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

      await queryInterface.addColumn(
        'vehicles',
        'photos',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { 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(
        'agences',
        'name',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

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

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

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

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

      await queryInterface.addColumn(
        'claims',
        'agencesId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'clients',
        'agencesId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'company_profiles',
        'agencesId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'drivers',
        'agencesId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

      await queryInterface.addColumn(
        'guarantees',
        'agencesId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'infractions',
        'agencesId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'invoices_saas',
        'agencesId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'maintenance',
        'agencesId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

      await queryInterface.addColumn(
        'plans',
        'agencesId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'reservations',
        'agencesId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

      await queryInterface.addColumn(
        'tenants',
        'agencesId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'vehicle_conditions',
        'agencesId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'vehicles',
        'agencesId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'agences',
            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('vehicles', 'agencesId', {
        transaction,
      });

      await queryInterface.removeColumn('vehicle_conditions', 'agencesId', {
        transaction,
      });

      await queryInterface.removeColumn('tenants', 'agencesId', {
        transaction,
      });

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

      await queryInterface.removeColumn('reservations', 'agencesId', {
        transaction,
      });

      await queryInterface.removeColumn('plans', 'agencesId', { transaction });

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

      await queryInterface.removeColumn('maintenance', 'agencesId', {
        transaction,
      });

      await queryInterface.removeColumn('invoices_saas', 'agencesId', {
        transaction,
      });

      await queryInterface.removeColumn('infractions', 'agencesId', {
        transaction,
      });

      await queryInterface.removeColumn('guarantees', 'agencesId', {
        transaction,
      });

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

      await queryInterface.removeColumn('drivers', 'agencesId', {
        transaction,
      });

      await queryInterface.removeColumn('company_profiles', 'agencesId', {
        transaction,
      });

      await queryInterface.removeColumn('clients', 'agencesId', {
        transaction,
      });

      await queryInterface.removeColumn('claims', 'agencesId', { transaction });

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

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

      await queryInterface.removeColumn('agences', '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('vehicles', 'photos', { transaction });

      await queryInterface.removeColumn('vehicles', 'tech_visit_expiry', {
        transaction,
      });

      await queryInterface.removeColumn('vehicles', 'insurance_expiry', {
        transaction,
      });

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

      await queryInterface.removeColumn('vehicles', 'daily_price', {
        transaction,
      });

      await queryInterface.removeColumn('vehicles', 'mileage', { transaction });

      await queryInterface.removeColumn('vehicles', 'transmission', {
        transaction,
      });

      await queryInterface.removeColumn('vehicles', 'fuel_type', {
        transaction,
      });

      await queryInterface.removeColumn('vehicles', 'category', {
        transaction,
      });

      await queryInterface.removeColumn('vehicles', 'color', { transaction });

      await queryInterface.removeColumn('vehicles', 'year', { transaction });

      await queryInterface.removeColumn('vehicles', 'model', { transaction });

      await queryInterface.removeColumn('vehicles', 'brand', { transaction });

      await queryInterface.removeColumn('vehicles', 'plate_number', {
        transaction,
      });

      await queryInterface.removeColumn('vehicles', 'tenantId', {
        transaction,
      });

      await queryInterface.removeColumn('vehicle_conditions', 'after', {
        transaction,
      });

      await queryInterface.removeColumn('vehicle_conditions', 'before', {
        transaction,
      });

      await queryInterface.removeColumn('vehicle_conditions', 'reservationId', {
        transaction,
      });

      await queryInterface.removeColumn('vehicle_conditions', 'tenantId', {
        transaction,
      });

      await queryInterface.removeColumn('tenants', 'billing_phone', {
        transaction,
      });

      await queryInterface.removeColumn('tenants', 'billing_email', {
        transaction,
      });

      await queryInterface.removeColumn('tenants', 'trial_ends_at', {
        transaction,
      });

      await queryInterface.removeColumn('tenants', 'planId', { transaction });

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

      await queryInterface.removeColumn('tenants', 'subdomain', {
        transaction,
      });

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

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

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

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

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

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

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

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

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

      await queryInterface.removeColumn('reservations', 'notes', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'return_validated_at', {
        transaction,
      });

      await queryInterface.removeColumn(
        'reservations',
        'departure_validated_at',
        { transaction },
      );

      await queryInterface.removeColumn('reservations', 'guarantee_status', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'guarantee_amount', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'guarantee_method', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'balance_amount', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'paid_amount', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'total_price', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'price_per_day', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'days', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'options', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'return_address', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'pickup_address', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'end_at', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'start_at', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'vehicleId', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'clientId', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'status_computed', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'status_manual', {
        transaction,
      });

      await queryInterface.removeColumn('reservations', 'ref', { transaction });

      await queryInterface.removeColumn('reservations', 'tenantId', {
        transaction,
      });

      await queryInterface.removeColumn('plans', 'limits', { transaction });

      await queryInterface.removeColumn('plans', 'price_mad', { transaction });

      await queryInterface.removeColumn('plans', 'period', { transaction });

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

      await queryInterface.removeColumn('plans', 'code', { transaction });

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

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

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

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

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

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

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

      await queryInterface.removeColumn('maintenance', 'attachments', {
        transaction,
      });

      await queryInterface.removeColumn('maintenance', 'notes', {
        transaction,
      });

      await queryInterface.removeColumn('maintenance', 'cost', { transaction });

      await queryInterface.removeColumn('maintenance', 'odometer', {
        transaction,
      });

      await queryInterface.removeColumn('maintenance', 'scheduled_at', {
        transaction,
      });

      await queryInterface.removeColumn('maintenance', 'type', { transaction });

      await queryInterface.removeColumn('maintenance', 'vehicleId', {
        transaction,
      });

      await queryInterface.removeColumn('maintenance', 'tenantId', {
        transaction,
      });

      await queryInterface.removeColumn('invoices_saas', 'pdf_url', {
        transaction,
      });

      await queryInterface.removeColumn('invoices_saas', 'issued_at', {
        transaction,
      });

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

      await queryInterface.removeColumn('invoices_saas', 'amount_mad', {
        transaction,
      });

      await queryInterface.removeColumn('invoices_saas', 'invoice_number', {
        transaction,
      });

      await queryInterface.removeColumn('invoices_saas', 'subscriptionId', {
        transaction,
      });

      await queryInterface.removeColumn('invoices_saas', 'tenantId', {
        transaction,
      });

      await queryInterface.removeColumn('infractions', 'proof_url', {
        transaction,
      });

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

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

      await queryInterface.removeColumn('infractions', 'location', {
        transaction,
      });

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

      await queryInterface.removeColumn('infractions', 'ref_no', {
        transaction,
      });

      await queryInterface.removeColumn('infractions', 'reservationId', {
        transaction,
      });

      await queryInterface.removeColumn('infractions', 'vehicleId', {
        transaction,
      });

      await queryInterface.removeColumn('infractions', 'tenantId', {
        transaction,
      });

      await queryInterface.removeColumn('guarantees', 'proof_url', {
        transaction,
      });

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

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

      await queryInterface.removeColumn('guarantees', 'method', {
        transaction,
      });

      await queryInterface.removeColumn('guarantees', 'reservationId', {
        transaction,
      });

      await queryInterface.removeColumn('guarantees', 'tenantId', {
        transaction,
      });

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

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

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

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

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

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

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

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

      await queryInterface.removeColumn('drivers', 'license_copy_url', {
        transaction,
      });

      await queryInterface.removeColumn('drivers', 'id_copy_url', {
        transaction,
      });

      await queryInterface.removeColumn('drivers', 'license_issue_date', {
        transaction,
      });

      await queryInterface.removeColumn('drivers', 'license_number', {
        transaction,
      });

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

      await queryInterface.removeColumn('drivers', 'reservationId', {
        transaction,
      });

      await queryInterface.removeColumn('drivers', 'tenantId', { transaction });

      await queryInterface.removeColumn('company_profiles', 'pdf_footer', {
        transaction,
      });

      await queryInterface.removeColumn('company_profiles', 'logo_url', {
        transaction,
      });

      await queryInterface.removeColumn('company_profiles', 'patente', {
        transaction,
      });

      await queryInterface.removeColumn('company_profiles', 'ice', {
        transaction,
      });

      await queryInterface.removeColumn('company_profiles', 'rc', {
        transaction,
      });

      await queryInterface.removeColumn('company_profiles', 'website', {
        transaction,
      });

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

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

      await queryInterface.removeColumn('company_profiles', 'address', {
        transaction,
      });

      await queryInterface.removeColumn('company_profiles', 'legal_name', {
        transaction,
      });

      await queryInterface.removeColumn('company_profiles', 'tenantId', {
        transaction,
      });

      await queryInterface.removeColumn('clients', 'license_copy_url', {
        transaction,
      });

      await queryInterface.removeColumn('clients', 'id_copy_url', {
        transaction,
      });

      await queryInterface.removeColumn('clients', 'license_issue_date', {
        transaction,
      });

      await queryInterface.removeColumn('clients', 'license_number', {
        transaction,
      });

      await queryInterface.removeColumn('clients', 'id_issue_date', {
        transaction,
      });

      await queryInterface.removeColumn('clients', 'id_number', {
        transaction,
      });

      await queryInterface.removeColumn('clients', 'id_type', { transaction });

      await queryInterface.removeColumn('clients', 'address', { transaction });

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

      await queryInterface.removeColumn('clients', 'birth_date', {
        transaction,
      });

      await queryInterface.removeColumn('clients', 'last_name', {
        transaction,
      });

      await queryInterface.removeColumn('clients', 'first_name', {
        transaction,
      });

      await queryInterface.removeColumn('clients', 'tenantId', { transaction });

      await queryInterface.removeColumn('claims', 'attachments', {
        transaction,
      });

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

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

      await queryInterface.removeColumn('claims', 'category', { transaction });

      await queryInterface.removeColumn('claims', 'reservationId', {
        transaction,
      });

      await queryInterface.removeColumn('claims', 'clientId', { transaction });

      await queryInterface.removeColumn('claims', 'tenantId', { 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('agences', { transaction });

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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