Skip to content

Raise error to make sure we convert all int IDs on converting any int ID to bigint.

What does this MR do?

As we have to Convert all integer IDs to bigint in the primar... (#465805 - closed) in Gitlab.com and the preparation is a time taking process, this MR makes sure that we convert all available int IDs while working migrating any int ID to bigint.

Reason for adding this check

Effort wise it's straight forward to include additional columns to initialize_conversion_of_integer_to_bigint and in our backfill batched background migration, but their impact is huge

Since the backfill migration will do a full table scan, we can backfill all IDs at a single scan rather than doing them separately. This will save us a lot of time, especially for large tables a single backfill migration would run for months.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Create a migration to initialize convertion for a table from db/table_integer_ids.yml, leaving at-least one int IDs unconverted behind.

    # frozen_string_literal: true
    
    class InitializeConversionOfAbuseReportsIntIdsToBigint < Gitlab::Database::Migration[2.2]
      disable_ddl_transaction!
      milestone '17.5'
    
      TABLE = :abuse_reports
      COLUMNS = %i[id assignee_id]
    
      def up
        initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
      end
    
      def down
        revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
      end
    end
    
  2. bundle exec rails db:migrate to run the migration, should throw an exception to include other pending INT ids as well.

    'abuse_reports' table still has ["reporter_id", "resolved_by_id", "user_id"] integer IDs. Please include them in the 'columns' param and in your backfill migration. For more info: https://gitlab.com/gitlab-org/gitlab/-/issues/482470
  3. Update the migration to include all integer IDs from 'abuse_reports' table.

    # frozen_string_literal: true
    
    class InitializeConversionOfAbuseReportsIntIdsToBigint < Gitlab::Database::Migration[2.2]
      disable_ddl_transaction!
      milestone '17.5'
    
      TABLE = :abuse_reports
      COLUMNS = %i[id assignee_id reporter_id resolved_by_id user_id]
    
      def up
        initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
      end
    
      def down
        revert_initialize_conversion_of_integer_to_bigint(TABLE, COLUMNS)
      end
    end
    
  4. Rerun the migration and this time there should not be any exceptions.

    • Also db/table_integer_ids.yml file should get updated to not include abuse_reports entries.

Related to #482470 (closed)

Edited by Prabakaran Murugesan

Merge request reports

Loading