-
Notifications
You must be signed in to change notification settings - Fork 127
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
Migrations aren't working because Mongo.Ecto.execute_ddl
isn't implemented
#182
Comments
@bdtomlin Sorry about that! Migrations aren't supported with this adapter. We should add that to the readme and throw a more helpful error message! |
@scottmessinger I saw issue #12, and #25 and thought the intent was to support a limited migration set (for changing data, adding indexes, and things like that). It would be good to make it clear if that is not the intent. It would be nice to support those features, but if not to give direction on other options for handling indexes and similar situations. |
Totally agree! @joeapearson ran into this here: commoncurriculum#2 (comment) and would also like to address this in the future. I'd welcome any PRs! |
@bdtomlin it doesn't really make sense to support migrations in the same way that they are in SQL land. IIRC there are some places in the Ecto code that make that assumption; this may be one of them. My idea (to be vetted by everyone else) would be to add some kind of separate index management feature, possibly augmented with the information we can get out of an Ecto.Schema. Can you say more about what you're specifically trying to accomplish? What does your DDL do? |
In cases like this (ones where Ecto makes an assumption that doesn't make total sense in Mongo land), I think we need an explicit |
It was not really a surprise when migrations failed. I understand how migrations in mongodb are a different animal that migrations in SQL. The surprising thing was that there was no intent to support migrations based on the issues I mentioned. I think migrations would be helpful for things such as fields being renamed, modified, or transformed. It is also useful for cleaning up data that is no longer in use, restructuring collections, etc. I understand if there is no intent to support migrations at all, and I agree that a better message would help, also maybe adding a comment to those issues I referenced saying it is not supported. FWIW, Mongoid does not support migrations either, but there is another gem that does: https://github.com/adacosta/mongoid_rails_migrations |
So, I guess the "official" policy (in that there is an official policy) is that @joeapearson and I would love to have some support for migrations in the adapter (especially or mainly index management) but have no current plans to implement them. We'd welcome any PRs to add support! In order of priorities, I would think:
Let me know if you get a chance to tackle this (even if in a different order than listed above) -- I'd be happy to review the PR! |
Yep sounds good. @bdtomlin it wasn't a "never", more of a "yes that sounds nice but no one has much time at the moment", so for now we're looking for a quick fix (like a nice error message, I know this isn't really a "fix" for you but at least you wouldn't have been left completely unaided), and then we're looking for consensus on what we'd like to build. @scottmessinger agree with your prioritisations. |
@bdtomlin do you have a simple repo that we can look at to work with on this? |
I saw this error. In my |
It looks like Ecto expects drivers to implement a function called
execute_ddl
that doesn't exist in mongodb_ecto.When running
mix ecto.migrate
that method it called in order to create the migrations table, and then it fails. Also note that the migrate task is not available unless you leave ecto_sql in place. So it seems like mongodb_ecto will need to implement that task as well.I expect there is some other stuff that is probably missing also like managing the schema migrations after the collection has been created.
Here's what happens when trying to migrate so to demonstrate the expected function signature:
The text was updated successfully, but these errors were encountered: