Sha256: 334c768689d5131b4a702be1256544483b46a7e2b52a79a56abdfad0bdd3a05e

Contents?: true

Size: 765 Bytes

Versions: 6

Compression:

Stored size: 765 Bytes

Contents

require "active_record/migration/compatibility"

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

  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
end

ActiveRecord::Migration.singleton_class.send(:prepend, PgHaMigrations::AllowedVersions)

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
pg_ha_migrations-1.2.2 lib/pg_ha_migrations/allowed_versions.rb
pg_ha_migrations-1.2.1 lib/pg_ha_migrations/allowed_versions.rb
pg_ha_migrations-1.2.0 lib/pg_ha_migrations/allowed_versions.rb
pg_ha_migrations-1.1.0 lib/pg_ha_migrations/allowed_versions.rb
pg_ha_migrations-1.0.0 lib/pg_ha_migrations/allowed_versions.rb
pg_ha_migrations-0.2.0 lib/pg_ha_migrations/allowed_versions.rb