You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've managed to monkeypatch a solution by overriding the default migrate task and am happy to submit a PR if needed: -
## RPECK 10/12/2024 - Fix to the ActiveRecord Migrate task in Padrino
## Any migrations performed have to pass the correct values to ActiveRecord
## --
## For versions of AR > 7.1, there seems to be an issue with the core migrate task, leading to an error citing:
## undefined method `create_table' for class ActiveRecord::SchemaMigration (NoMethodError)
## -
## The solution is to ensure that the correct values are passed to ActiveRecord, which we've achieved here with a monkeypatch
## Ref: ./padrino-gen/lib/padrino-gen/padrino-tasks/activerecord.rb
namespace :ar do
task :migrate => :environment do
Rake::Task["ar:migrate"].clear
if PadrinoTasks.load?(:activerecord, defined?(ActiveRecord))
ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
if less_than_active_record_5_2?
ActiveRecord::Migrator.migrate("db/migrate/", env_migration_version)
elsif less_than_active_record_6_0? || greater_than_active_record_7_1? ## RPECK 18/12/2024 -> added logic here
ActiveRecord::MigrationContext.new("db/migrate/").migrate(env_migration_version)
else
ActiveRecord::MigrationContext.new("db/migrate/", ActiveRecord::SchemaMigration).migrate(env_migration_version)
end
if less_than_active_record_7_0?
Rake::Task["ar:schema:dump"].invoke if ActiveRecord::Base.schema_format == :ruby
else
Rake::Task["ar:schema:dump"].invoke if ActiveRecord.schema_format == :ruby
end
end
end
def greater_than_active_record_7_1?
ActiveRecord.version > Gem::Version.create("7.1.0")
end
end
The text was updated successfully, but these errors were encountered:
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
padrino ar:migrate
crashes out citingcreate_table
function not found when using ActiveRecord 7.2+What is the expected behavior?
padrino ar:migrate
will process the migrations as per ActiveRecord's standard functionalityWhich versions of Ruby, Padrino, Sinatra, Rack, OS are you using? Did this work in previous versions?
Ruby 3.3.6, Padrino 16.pre.3
Upon further investigation, the issue is caused by the following: -
padrino-framework/padrino-gen/lib/padrino-gen/padrino-tasks/activerecord.rb
Line 136 in 283a22b
This is incorrect for ActiveRecord 7.2, it should be the same as AR 6.0: -
padrino-framework/padrino-gen/lib/padrino-gen/padrino-tasks/activerecord.rb
Line 134 in 283a22b
I've managed to monkeypatch a solution by overriding the default migrate task and am happy to submit a PR if needed: -
The text was updated successfully, but these errors were encountered: