diff --git a/lib/generators/good_job/install_generator.rb b/lib/generators/good_job/install_generator.rb index 679b11568..0dffd1411 100644 --- a/lib/generators/good_job/install_generator.rb +++ b/lib/generators/good_job/install_generator.rb @@ -19,5 +19,11 @@ class InstallGenerator < Rails::Generators::Base def create_migration_file migration_template 'migrations/create_good_jobs.rb.erb', File.join(db_migrate_path, "create_good_jobs.rb") end + + private + + def migration_version + "[#{ActiveRecord::VERSION::STRING.to_f}]" + end end end diff --git a/lib/generators/good_job/templates/install/migrations/create_good_jobs.rb.erb b/lib/generators/good_job/templates/install/migrations/create_good_jobs.rb.erb index fdd772ccc..27e5d054a 100644 --- a/lib/generators/good_job/templates/install/migrations/create_good_jobs.rb.erb +++ b/lib/generators/good_job/templates/install/migrations/create_good_jobs.rb.erb @@ -1,5 +1,5 @@ # frozen_string_literal: true -class CreateGoodJobs < ActiveRecord::Migration[5.2] +class CreateGoodJobs < ActiveRecord::Migration<%= migration_version %> def change enable_extension 'pgcrypto' diff --git a/lib/generators/good_job/templates/update/migrations/01_create_good_jobs.rb b/lib/generators/good_job/templates/update/migrations/01_create_good_jobs.rb.erb similarity index 93% rename from lib/generators/good_job/templates/update/migrations/01_create_good_jobs.rb rename to lib/generators/good_job/templates/update/migrations/01_create_good_jobs.rb.erb index fdd772ccc..27e5d054a 100644 --- a/lib/generators/good_job/templates/update/migrations/01_create_good_jobs.rb +++ b/lib/generators/good_job/templates/update/migrations/01_create_good_jobs.rb.erb @@ -1,5 +1,5 @@ # frozen_string_literal: true -class CreateGoodJobs < ActiveRecord::Migration[5.2] +class CreateGoodJobs < ActiveRecord::Migration<%= migration_version %> def change enable_extension 'pgcrypto' diff --git a/lib/generators/good_job/update_generator.rb b/lib/generators/good_job/update_generator.rb index e767df966..85494e679 100644 --- a/lib/generators/good_job/update_generator.rb +++ b/lib/generators/good_job/update_generator.rb @@ -24,5 +24,11 @@ def update_migration_files migration_template "migrations/#{template_file}", File.join(db_migrate_path, destination_file), skip: true end end + + private + + def migration_version + "[#{ActiveRecord::VERSION::STRING.to_f}]" + end end end