ilyakatz / data-migrate

Migrate and update data alongside your database structure.
MIT License
1.4k stars 192 forks source link

data-migrate breaks after upgrade to rails 7 #191

Closed aka47 closed 1 hour ago

aka47 commented 3 years ago

Rails 7 is the next release coming up.

in our Gemfile we have gem "rails", "7.0.0.alpha", git: 'https://github.com/rails/rails.git', branch: 'main'

An upgrade is not possible with data-migrate because of the following exception:

NameError: undefined method `migrations_status' for class `#<Class:DataMigrate::DataMigrator>'
/Users/tim/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/data_migrate-7.0.1/lib/data_migrate/data_migrator.rb:23:in `alias_method'
/Users/tim/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/data_migrate-7.0.1/lib/data_migrate/data_migrator.rb:23:in `singleton class'
/Users/tim/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/data_migrate-7.0.1/lib/data_migrate/data_migrator.rb:22:in `<class:DataMigrator>'
/Users/tim/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/data_migrate-7.0.1/lib/data_migrate/data_migrator.rb:6:in `<module:DataMigrate>'
/Users/tim/.rbenv/versions/3.0.1/lib/ruby/gems/3.0.0/gems/data_migrate-7.0.1/lib/data_migrate/data_migrator.rb:5:in `<main>'

this PR might be a helpful start .. https://github.com/rails/rails/pull/40806

afomera commented 3 years ago

I also ran into this tonight.

Looks like it's related to the Major version bump from 6 to 7 and some various places checking for it to be 6 to set the migration context and whatnot.

I started a branch here on a fork: https://github.com/podia/data-migrate/tree/rails-7, but ran into trouble trying to setup/run tests in the project here.

If you're curious, I created a sample app to reproduce the issues here: https://github.com/afomera/data-migrate-rails-7 (use rails-6 branch after cloning it locally to bundle / create the Postgres db successfully).

After running bundle, trying to run bin/rails server on a basic Rails 7 install fails, unless you use the fork version with the changes to lib/data_migrate.rb to extend the check for the major Rails 7 version.

I ran out of time tonight to continue trying to get specs to run, but maybe this gets things going a little further.

aka47 commented 2 years ago

started a PR https://github.com/ilyakatz/data-migrate/pull/198

bmulholland commented 2 years ago

Shouldn't https://github.com/ilyakatz/data-migrate/pull/204 have closed this?

Morozzzko commented 1 hour ago

Think it's safe to say this one is fixed* now