Module: Gitlab::Database::MigrationHelpers::ConvertToBigint

Defined in:
lib/gitlab/database/migration_helpers/convert_to_bigint.rb

Instance Method Summary collapse

Instance Method Details

#columns_swapped?(table_name, column_name) ⇒ Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
29
30
31
# File 'lib/gitlab/database/migration_helpers/convert_to_bigint.rb', line 23

def columns_swapped?(table_name, column_name)
  table_columns = columns(table_name.to_s)
  temp_column_name = convert_to_bigint_column(column_name)

  column = table_columns.find { |c| c.name == column_name.to_s }
  temp_column = table_columns.find { |c| c.name == temp_column_name }

  column.sql_type == 'bigint' && temp_column.sql_type == 'integer'
end

#com_or_dev_or_test_but_not_jh?Boolean

This helper is extracted for the purpose of gitlab.com/gitlab-org/gitlab/-/issues/392815 so that we can test all combinations just once, and simplify migration tests.

Once we are done with the PK conversions we can remove this.

Returns:

  • (Boolean)


13
14
15
16
17
# File 'lib/gitlab/database/migration_helpers/convert_to_bigint.rb', line 13

def com_or_dev_or_test_but_not_jh?
  return true if Gitlab.dev_or_test_env?

  Gitlab.com? && !Gitlab.jh?
end

#temp_column_removed?(table_name, column_name) ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/gitlab/database/migration_helpers/convert_to_bigint.rb', line 19

def temp_column_removed?(table_name, column_name)
  !column_exists?(table_name.to_s, convert_to_bigint_column(column_name))
end