-
Notifications
You must be signed in to change notification settings - Fork 194
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NoMethodError (undefined method `exists?' for DataMigrate::DataSchemaMigration:Class) #230
Comments
@defsprite do you have any recommendations on how to go about this? |
Same with any ActiveRecords methods not explicitly delegated (all, delete_all etc). I had to nail down version 8.1.1 to get around this problem. |
@ilyakatz I'm not sure whether If that is the case, we may want to reconsider the delegation approach (i.e revert the change) and look into restructuring how the gem is loaded in https://github.com/ilyakatz/data-migrate/blob/master/lib/data_migrate.rb in order to avoid eagerly making database connections. What do you think? |
We changed our code to I hope Issue can be closed if @elik-ru can do the same "fix". |
In this commit In this commit kind of reverts the change:
@defsprite, @wildmaples I'm a little bit confused, which way is better? And what were the intentions behind the changes. |
@rocket-turtle The commit was meant as a fix for #222 - because just loading the gem forces an active database connection to be present. However, a lot of (or very vocal) people seem to be relying on the fact that |
Thank you for your reply. If I understand it correct the So with the switch back to "inherit from ActiveRecord::SchemaMigration" the gem loads AR to early? Is there a way to navigate to the pull request of an commit. For example from 9dda061 to #229 |
Yes, I can verify this problem exists in version 9.2.0 using the bug app provided. I think there are two ways to go about this:
I'd probably tend to the latter solution, because the delegation approach is confusing and unobvious (as it looks to me it was just accidentally reverted). The problem described (forcing a db connection to be present) is also a widespread issue in many gems, so you'll end up up using a nulldb adapter approach anyway at some point. We may as well just close the issue #222 as wontfix. Apologies to the community for creating breaking API changes for a rather minor issue that cause extra work dealing with it (for the second time now) TLDR: I'd recommend keeping the inheritance approach and fix the gem loading eventually. |
FWIW.. Rails 7.1 makes |
Hi there,
this commit broke our code:
9dda061
We use
DataMigrate::DataSchemaMigration.exists?
to check if any data_migration allready ran.It's
true
if we set up a new system. With the commit above we can useDataMigrate::DataSchemaMigration.instance.exists?
for the check. Is it the correct way to do this or should we use a different technique?Thank you for your help and time providing this gem.
The text was updated successfully, but these errors were encountered: