Skip to content

Enforcing Gitlab::Database::Migration[2.1] as new DB migration version

Omar Qunsul requested to merge 384735-disallow-migration-version-2-0 into master

What does this MR do and why?

This MR is the 2nd and last step in the issue: #384735 (closed)

Disallowing Gitlab::Database::Migration[2.0] from now on, and enforcing Gitlab::Database::Migration[2.1] for any new database migration.

Gitlab::Database::Migration[2.1] has been the default generated migration since it was introduced in this MR. Then it was followed by this follow up MR to update the documentation and allow Gitlab::Database::Migration[2.1] in Rubocop.

I will announce this change on the internal Slack channels #backend, #database once this is merged

How to verify locally?

Create a test migration, for example

# frozen_string_literal: true

class OmarTest < Gitlab::Database::Migration[2.0]
  def change; end
end

Then run

bundle exec rubocop db/migrate/

You should see

db/migrate/20230118105214_omar_test.rb:3:1: C: Migration/VersionedMigrationClass: Don't inherit from ActiveRecord::Migration or old versions of Gitlab::Database::Migration. Use Gitlab::Database::Migration[2.1] instead. See https://docs.gitlab.com/ee/development/migration_style_guide.html#migration-helpers-and-versioning.
class OmarTest < Gitlab::Database::Migration[2.0] ...
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #384735 (closed)

Edited by Omar Qunsul

Merge request reports