Module: PgHaMigrations::AllowedVersions

Defined in:
lib/pg_ha_migrations/allowed_versions.rb

Constant Summary collapse

ALLOWED_VERSIONS =
[4.2, 5.0, 5.1, 5.2, 6.0, 6.1].map do |v|
  begin
    ActiveRecord::Migration[v]
  rescue ArgumentError
    nil
  end
end.compact

Instance Method Summary collapse

Instance Method Details

#inherited(subclass) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/pg_ha_migrations/allowed_versions.rb', line 12

def inherited(subclass)
  super
  unless ALLOWED_VERSIONS.include?(subclass.superclass)
    raise StandardError, "#{subclass.superclass} is not a permitted migration class\n" \
      "\n" \
      "To add a new version update the ALLOWED_VERSIONS constant in #{__FILE__}\n" \
      "Currently allowed versions: #{ALLOWED_VERSIONS.map { |v| "ActiveRecord::Migration[#{v.current_version}]" }.join(', ')}"
  end
end