Skip to content

Danger: Adds a new Danger check for changing column default

What does this MR do and why?

This MR adds a check that detects usage of change_column_default in migrations, and adds a comment to the changed lines, indicating the need to explicitly declare this column as changing default. This is needed in order to reduce the chance for incidents like RCA: Stale database schema problem caused by `d... (#427489 - closed).

How to set up and validate locally

  1. Locally commit a migration that is using the change_column_default helper. Example:

    # frozen_string_literal: true
    
    class Test1 < Gitlab::Database::Migration[2.1]
      enable_lock_retries!
    
      def change
        change_column_default('ci_builds', 'partition_id', from: 100, to: 101)
      end
    end
  2. Run bin/rake danger_local

  3. Check the output for the new comment message.

MR acceptance checklist

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

Merge request reports

Loading