diff --git a/lib/generators/fx/function/function_generator.rb b/lib/generators/fx/function/function_generator.rb index 613fcbf..6ecee3b 100644 --- a/lib/generators/fx/function/function_generator.rb +++ b/lib/generators/fx/function/function_generator.rb @@ -71,10 +71,6 @@ def migration_class_name end end - def active_record_migration_class - migration_helper.active_record_migration_class - end - def formatted_name NameHelper.format_for_migration(singular_name) end diff --git a/lib/generators/fx/function/templates/db/migrate/create_function.erb b/lib/generators/fx/function/templates/db/migrate/create_function.erb index 5deacd4..34f259c 100644 --- a/lib/generators/fx/function/templates/db/migrate/create_function.erb +++ b/lib/generators/fx/function/templates/db/migrate/create_function.erb @@ -1,4 +1,4 @@ -class <%= migration_class_name %> < <%= active_record_migration_class %> +class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>] def change create_function <%= formatted_name %> end diff --git a/lib/generators/fx/function/templates/db/migrate/update_function.erb b/lib/generators/fx/function/templates/db/migrate/update_function.erb index 3d2a427..738b112 100644 --- a/lib/generators/fx/function/templates/db/migrate/update_function.erb +++ b/lib/generators/fx/function/templates/db/migrate/update_function.erb @@ -1,4 +1,4 @@ -class <%= migration_class_name %> < <%= active_record_migration_class %> +class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>] def change update_function <%= formatted_name %>, version: <%= version %>, revert_to_version: <%= previous_version %> end diff --git a/lib/generators/fx/migration_helper.rb b/lib/generators/fx/migration_helper.rb index a97c139..8cbe042 100644 --- a/lib/generators/fx/migration_helper.rb +++ b/lib/generators/fx/migration_helper.rb @@ -10,14 +10,6 @@ def skip_creation? !should_create_migration? end - def active_record_migration_class - if ActiveRecord::Migration.respond_to?(:current_version) - "ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}]" - else - "ActiveRecord::Migration" - end - end - def update_migration_class_name(object_type:, class_name:, version:) "Update#{object_type.capitalize}#{class_name}ToVersion#{version}" end diff --git a/lib/generators/fx/trigger/templates/db/migrate/create_trigger.erb b/lib/generators/fx/trigger/templates/db/migrate/create_trigger.erb index b251f4c..d8e4b1c 100644 --- a/lib/generators/fx/trigger/templates/db/migrate/create_trigger.erb +++ b/lib/generators/fx/trigger/templates/db/migrate/create_trigger.erb @@ -1,4 +1,4 @@ -class <%= migration_class_name %> < <%= active_record_migration_class %> +class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>] def change create_trigger <%= formatted_name %>, on: <%= formatted_table_name %> end diff --git a/lib/generators/fx/trigger/templates/db/migrate/update_trigger.erb b/lib/generators/fx/trigger/templates/db/migrate/update_trigger.erb index cb8a808..dbe3e56 100644 --- a/lib/generators/fx/trigger/templates/db/migrate/update_trigger.erb +++ b/lib/generators/fx/trigger/templates/db/migrate/update_trigger.erb @@ -1,4 +1,4 @@ -class <%= migration_class_name %> < <%= active_record_migration_class %> +class <%= migration_class_name %> < ActiveRecord::Migration[<%= ActiveRecord::Migration.current_version %>] def change update_trigger <%= formatted_name %>, on: <%= formatted_table_name %>, version: <%= version %>, revert_to_version: <%= previous_version %> end diff --git a/lib/generators/fx/trigger/trigger_generator.rb b/lib/generators/fx/trigger/trigger_generator.rb index b8b9c26..b64453e 100644 --- a/lib/generators/fx/trigger/trigger_generator.rb +++ b/lib/generators/fx/trigger/trigger_generator.rb @@ -65,10 +65,6 @@ def migration_class_name end end - def active_record_migration_class - migration_helper.active_record_migration_class - end - def formatted_name NameHelper.format_for_migration(singular_name) end diff --git a/spec/generators/fx/migration_helper_spec.rb b/spec/generators/fx/migration_helper_spec.rb index 668169a..485b820 100644 --- a/spec/generators/fx/migration_helper_spec.rb +++ b/spec/generators/fx/migration_helper_spec.rb @@ -16,31 +16,6 @@ end end - describe "#active_record_migration_class" do - it "returns versioned migration class when current_version is available" do - allow(ActiveRecord::Migration).to receive(:current_version) - .and_return(7.0) - - helper = described_class.new({}) - - expect(helper.active_record_migration_class).to eq( - "ActiveRecord::Migration[7.0]" - ) - end - - it "returns base migration class when current_version is not available" do - allow(ActiveRecord::Migration).to receive(:respond_to?) - .with(:current_version) - .and_return(false) - - helper = described_class.new({}) - - expect(helper.active_record_migration_class).to eq( - "ActiveRecord::Migration" - ) - end - end - describe "#update_migration_class_name" do it "generates correct class name for functions" do helper = described_class.new({})