Module: SafePgMigrations::Helpers::SatisfiedHelper

Included in:
Polyfills::IndexDefinitionPolyfill
Defined in:
lib/safe-pg-migrations/helpers/satisfied_helper.rb

Class Method Summary collapse

Class Method Details

.satisfied?(version) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/safe-pg-migrations/helpers/satisfied_helper.rb', line 25

def satisfied?(version)
  Gem::Requirement.new(version).satisfied_by? Gem::Version.new(::ActiveRecord::VERSION::STRING)
end

.satisfies_add_check_constraints!Object

Raises:

  • (NotImplementedError)


11
12
13
14
15
# File 'lib/safe-pg-migrations/helpers/satisfied_helper.rb', line 11

def satisfies_add_check_constraints!
  return if satisfies_add_check_constraints?

  raise NotImplementedError, 'add_check_constraint is not supported in your ActiveRecord version'
end

.satisfies_add_check_constraints?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/safe-pg-migrations/helpers/satisfied_helper.rb', line 17

def satisfies_add_check_constraints?
  satisfied? '>=6.1.0'
end

.satisfies_add_column_update_rows_backfill?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/safe-pg-migrations/helpers/satisfied_helper.rb', line 21

def satisfies_add_column_update_rows_backfill?
  satisfies_change_column_null_requirements?
end

.satisfies_change_column_null_requirements?Boolean

Returns:

  • (Boolean)


7
8
9
# File 'lib/safe-pg-migrations/helpers/satisfied_helper.rb', line 7

def satisfies_change_column_null_requirements?
  satisfies_add_check_constraints? && SafePgMigrations.pg_version_num >= 120_000
end