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(
        'analytics_daily',
        {
          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(
        'analytics_events',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

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

      await queryInterface.createTable(
        'blocks',
        {
          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(
        'button_links',
        {
          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(
        'domain_mappings',
        {
          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(
        'email_logs',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'feature_flags',
        {
          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(
        'flags',
        {
          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(
        'media_assets',
        {
          id: {
            type: Sequelize.DataTypes.UUID,
            defaultValue: Sequelize.DataTypes.UUIDV4,
            primaryKey: true,
          },
          createdById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          updatedById: {
            type: Sequelize.DataTypes.UUID,
            references: {
              key: 'id',
              model: 'users',
            },
          },
          createdAt: { type: Sequelize.DataTypes.DATE },
          updatedAt: { type: Sequelize.DataTypes.DATE },
          deletedAt: { type: Sequelize.DataTypes.DATE },
          importHash: {
            type: Sequelize.DataTypes.STRING(255),
            allowNull: true,
            unique: true,
          },
        },
        { transaction },
      );

      await queryInterface.createTable(
        'payment_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(
        '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(
        'profile_pages',
        {
          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(
        'social_links',
        {
          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(
        'templates',
        {
          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(
        'organizations',
        {
          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(
        'analytics_daily',
        'profile_pageId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

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

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

      await queryInterface.addColumn(
        'analytics_events',
        'profile_pageId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

          values: ['VISIT', 'CLICK'],
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'analytics_events',
        'linkId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

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

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

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

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

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

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

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

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

      await queryInterface.addColumn(
        'blocks',
        'profile_pageId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

          values: [
            'HERO',
            'TEXT',
            'BUTTONS',
            'SOCIALS',
            'IMAGE',
            'MAP',
            'SPACER',
          ],
        },
        { transaction },
      );

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

      await queryInterface.addColumn(
        'blocks',
        'visible',
        {
          type: Sequelize.DataTypes.BOOLEAN,

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

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

      await queryInterface.addColumn(
        'button_links',
        'blockId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

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

      await queryInterface.addColumn(
        'button_links',
        'enabled',
        {
          type: Sequelize.DataTypes.BOOLEAN,

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

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

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

      await queryInterface.addColumn(
        'domain_mappings',
        'userId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'domain_mappings',
        'profile_pageId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

          values: ['UNVERIFIED', 'VERIFYING', 'ACTIVE', 'ERROR'],
        },
        { transaction },
      );

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

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

          values: ['PENDING', 'ACTIVE', 'ERROR'],
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'email_logs',
        'userId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

          values: ['WELCOME', 'WEEKLY_SUMMARY', 'PASSWORD_RESET'],
        },
        { transaction },
      );

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

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

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

          values: ['SENT', 'BOUNCED', 'FAILED'],
        },
        { transaction },
      );

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

      await queryInterface.addColumn(
        'feature_flags',
        'value',
        {
          type: Sequelize.DataTypes.BOOLEAN,

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

      await queryInterface.addColumn(
        'flags',
        'profile_pageId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

          values: ['COPYRIGHT', 'BRAND_ABUSE', 'MALWARE', 'OTHER'],
        },
        { transaction },
      );

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

          values: ['OPEN', 'RESOLVED', 'REJECTED'],
        },
        { transaction },
      );

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

      await queryInterface.addColumn(
        'media_assets',
        'userId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

          values: ['IMAGE', 'AVATAR'],
        },
        { transaction },
      );

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

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

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

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

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

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

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

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

          values: ['STRIPE', 'WOMPI', 'WEP'],
        },
        { transaction },
      );

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

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

          values: ['PENDING', 'SUCCEEDED', 'FAILED', 'REFUNDED'],
        },
        { transaction },
      );

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

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

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

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

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

      await queryInterface.addColumn(
        'plans',
        'is_active',
        {
          type: Sequelize.DataTypes.BOOLEAN,

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

      await queryInterface.addColumn(
        'profile_pages',
        'userId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

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

      await queryInterface.addColumn(
        'profile_pages',
        'theme_templateId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

          values: ['DRAFT', 'PUBLISHED', 'SUSPENDED'],
        },
        { transaction },
      );

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

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

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

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

      await queryInterface.addColumn(
        'social_links',
        'blockId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

          values: [
            'TWITTER',
            'INSTAGRAM',
            'YOUTUBE',
            'TIKTOK',
            'FACEBOOK',
            'LINKEDIN',
            'GITHUB',
            'CUSTOM',
          ],
        },
        { transaction },
      );

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

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

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

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

          references: {
            model: 'users',
            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: ['TRIAL', 'ACTIVE', 'PAST_DUE', 'CANCELED'],
        },
        { transaction },
      );

      await queryInterface.addColumn(
        'subscriptions',
        'trial_ends_at',
        {
          type: Sequelize.DataTypes.DATE,
        },
        { 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',
        'cancel_at_period_end',
        {
          type: Sequelize.DataTypes.BOOLEAN,

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

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

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

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

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

          values: ['NEO_BRUTALISM', 'MODERN', 'FLAT'],
        },
        { transaction },
      );

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

      await queryInterface.addColumn(
        'templates',
        'is_premium',
        {
          type: Sequelize.DataTypes.BOOLEAN,

          defaultValue: false,
          allowNull: false,
        },
        { 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(
        'organizations',
        'name',
        {
          type: Sequelize.DataTypes.TEXT,
        },
        { transaction },
      );

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

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

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

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

      await queryInterface.addColumn(
        'analytics_daily',
        'organizationsId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'analytics_events',
        'organizationsId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

      await queryInterface.addColumn(
        'blocks',
        'organizationsId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'button_links',
        'organizationsId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'domain_mappings',
        'organizationsId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'email_logs',
        'organizationsId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'feature_flags',
        'organizationsId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'flags',
        'organizationsId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'media_assets',
        'organizationsId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'payment_transactions',
        'organizationsId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

      await queryInterface.addColumn(
        'profile_pages',
        'organizationsId',
        {
          type: Sequelize.DataTypes.UUID,

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

      await queryInterface.addColumn(
        'social_links',
        'organizationsId',
        {
          type: Sequelize.DataTypes.UUID,

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

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

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

      await queryInterface.addColumn(
        'templates',
        'organizationsId',
        {
          type: Sequelize.DataTypes.UUID,

          references: {
            model: 'organizations',
            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('templates', 'organizationsId', {
        transaction,
      });

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

      await queryInterface.removeColumn('social_links', 'organizationsId', {
        transaction,
      });

      await queryInterface.removeColumn('profile_pages', 'organizationsId', {
        transaction,
      });

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

      await queryInterface.removeColumn(
        'payment_transactions',
        'organizationsId',
        { transaction },
      );

      await queryInterface.removeColumn('media_assets', 'organizationsId', {
        transaction,
      });

      await queryInterface.removeColumn('flags', 'organizationsId', {
        transaction,
      });

      await queryInterface.removeColumn('feature_flags', 'organizationsId', {
        transaction,
      });

      await queryInterface.removeColumn('email_logs', 'organizationsId', {
        transaction,
      });

      await queryInterface.removeColumn('domain_mappings', 'organizationsId', {
        transaction,
      });

      await queryInterface.removeColumn('button_links', 'organizationsId', {
        transaction,
      });

      await queryInterface.removeColumn('blocks', 'organizationsId', {
        transaction,
      });

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

      await queryInterface.removeColumn('analytics_events', 'organizationsId', {
        transaction,
      });

      await queryInterface.removeColumn('analytics_daily', 'organizationsId', {
        transaction,
      });

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

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

      await queryInterface.removeColumn('organizations', '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('templates', 'is_premium', {
        transaction,
      });

      await queryInterface.removeColumn('templates', 'colors', { transaction });

      await queryInterface.removeColumn('templates', 'variant', {
        transaction,
      });

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

      await queryInterface.removeColumn('templates', 'key', { transaction });

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

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

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

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

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

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

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

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

      await queryInterface.removeColumn('social_links', 'order_index', {
        transaction,
      });

      await queryInterface.removeColumn('social_links', 'url', { transaction });

      await queryInterface.removeColumn('social_links', 'handle', {
        transaction,
      });

      await queryInterface.removeColumn('social_links', 'network', {
        transaction,
      });

      await queryInterface.removeColumn('social_links', 'blockId', {
        transaction,
      });

      await queryInterface.removeColumn('profile_pages', 'og_image_url', {
        transaction,
      });

      await queryInterface.removeColumn('profile_pages', 'og_description', {
        transaction,
      });

      await queryInterface.removeColumn('profile_pages', 'og_title', {
        transaction,
      });

      await queryInterface.removeColumn('profile_pages', 'published_at', {
        transaction,
      });

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

      await queryInterface.removeColumn('profile_pages', 'theme_templateId', {
        transaction,
      });

      await queryInterface.removeColumn('profile_pages', 'bio', {
        transaction,
      });

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

      await queryInterface.removeColumn('profile_pages', 'slug', {
        transaction,
      });

      await queryInterface.removeColumn('profile_pages', 'userId', {
        transaction,
      });

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

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

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

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

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

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

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

      await queryInterface.removeColumn('payment_transactions', 'psp_txn_id', {
        transaction,
      });

      await queryInterface.removeColumn(
        'payment_transactions',
        'psp_provider',
        { transaction },
      );

      await queryInterface.removeColumn('payment_transactions', 'currency', {
        transaction,
      });

      await queryInterface.removeColumn(
        'payment_transactions',
        'amount_cents',
        { transaction },
      );

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

      await queryInterface.removeColumn('media_assets', 'size_bytes', {
        transaction,
      });

      await queryInterface.removeColumn('media_assets', 'height', {
        transaction,
      });

      await queryInterface.removeColumn('media_assets', 'width', {
        transaction,
      });

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

      await queryInterface.removeColumn('media_assets', 'url', { transaction });

      await queryInterface.removeColumn('media_assets', 'userId', {
        transaction,
      });

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

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

      await queryInterface.removeColumn('flags', 'reason', { transaction });

      await queryInterface.removeColumn('flags', 'profile_pageId', {
        transaction,
      });

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

      await queryInterface.removeColumn('feature_flags', 'key', {
        transaction,
      });

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

      await queryInterface.removeColumn('email_logs', 'provider_id', {
        transaction,
      });

      await queryInterface.removeColumn('email_logs', 'to_email', {
        transaction,
      });

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

      await queryInterface.removeColumn('email_logs', 'userId', {
        transaction,
      });

      await queryInterface.removeColumn('domain_mappings', 'ssl_status', {
        transaction,
      });

      await queryInterface.removeColumn(
        'domain_mappings',
        'verification_token',
        { transaction },
      );

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

      await queryInterface.removeColumn('domain_mappings', 'domain', {
        transaction,
      });

      await queryInterface.removeColumn('domain_mappings', 'profile_pageId', {
        transaction,
      });

      await queryInterface.removeColumn('domain_mappings', 'userId', {
        transaction,
      });

      await queryInterface.removeColumn('button_links', 'click_count', {
        transaction,
      });

      await queryInterface.removeColumn('button_links', 'order_index', {
        transaction,
      });

      await queryInterface.removeColumn('button_links', 'enabled', {
        transaction,
      });

      await queryInterface.removeColumn('button_links', 'icon', {
        transaction,
      });

      await queryInterface.removeColumn('button_links', 'url', { transaction });

      await queryInterface.removeColumn('button_links', 'label', {
        transaction,
      });

      await queryInterface.removeColumn('button_links', 'blockId', {
        transaction,
      });

      await queryInterface.removeColumn('blocks', 'config', { transaction });

      await queryInterface.removeColumn('blocks', 'visible', { transaction });

      await queryInterface.removeColumn('blocks', 'order_index', {
        transaction,
      });

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

      await queryInterface.removeColumn('blocks', 'profile_pageId', {
        transaction,
      });

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

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

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

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

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

      await queryInterface.removeColumn('analytics_events', 'occurred_at', {
        transaction,
      });

      await queryInterface.removeColumn('analytics_events', 'ip_hash', {
        transaction,
      });

      await queryInterface.removeColumn('analytics_events', 'user_agent', {
        transaction,
      });

      await queryInterface.removeColumn('analytics_events', 'referrer', {
        transaction,
      });

      await queryInterface.removeColumn('analytics_events', 'linkId', {
        transaction,
      });

      await queryInterface.removeColumn('analytics_events', 'event_type', {
        transaction,
      });

      await queryInterface.removeColumn('analytics_events', 'profile_pageId', {
        transaction,
      });

      await queryInterface.removeColumn('analytics_daily', 'top_referrers', {
        transaction,
      });

      await queryInterface.removeColumn('analytics_daily', 'clicks', {
        transaction,
      });

      await queryInterface.removeColumn('analytics_daily', 'visits', {
        transaction,
      });

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

      await queryInterface.removeColumn('analytics_daily', 'profile_pageId', {
        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('organizations', { transaction });

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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