Skip to content

Commit

Permalink
Add migration version to install/update generator templates (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
bensheldon authored Oct 18, 2021
1 parent 377cde2 commit 71b52d6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
6 changes: 6 additions & 0 deletions lib/generators/good_job/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
Original file line number Diff line number Diff line change
@@ -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'

Expand Down
6 changes: 6 additions & 0 deletions lib/generators/good_job/update_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 71b52d6

Please sign in to comment.