rust-db / refinery

Powerful SQL migration toolkit for Rust.
MIT License
1.34k stars 126 forks source link

support for mongo? #126

Open JimLynchCodes opened 4 years ago

JimLynchCodes commented 4 years ago

Hi, sorry if this already answered here somewhere, but I am curious if support for mongodb and other NoSql databases is on the roadmap or if I should be looking at another tool for doing mongo migrations for my rust micro-services.

Thanks!

jxs commented 4 years ago

Hi, and thanks for your interest. So when we first created refinery it was for relational databases, therefore the Transaction and Query traits. That being said, support for NoSql databases such mongodb could be a super interesting addition Would you be willing to tackle this?

JimLynchCodes commented 4 years ago

I'm still a noob Rust dev and haven't look into the internals of this package at all so... I'm probably not the right person to do it. 😅

jxs commented 4 years ago

No worries, If you want to give it a try and have any questions I am on the Rust discord!

JimLynchCodes commented 4 years ago

Alright, thanks @jxs I'll try to find you on discord. :)

I think the "Query" side could work with Mongo with a very similar API after just changing "table" to "document" or "doc" and allowing Mongo-specific types like ObjectId and IsoDate.

Also, maybe a dumb question, but as a user of this library are you supposed to code out by hand the migration functions (eg. this one)? It is possible somehow to generate the migration implementation from changes to some special struct?

JimLynchCodes commented 4 years ago

Transactions would be great as well although I think it is still under development for the official mongodb rust driver.

jxs commented 4 years ago

I think the "Query" side could work with Mongo with a very similar API after just changing "table" to "document" or "doc" and allowing Mongo-specific types like ObjectId and IsoDate.

you need to also implement Transaction as migrate requires T: Transaction, though it doesn't need to be a transaction if the driver doesn't support it.

Also, maybe a dumb question, but as a user of this library are you supposed to code out by hand the migration functions (eg. this one)? It is possible somehow to generate the migration implementation from changes to some special struct?

you can either have migrations from a rust module, or from a .sql file, In Mongo's case it should be a .json

IgnisDa commented 1 year ago

@jxs Could you please share your discord username? Mine is IgnisDa#5244.

I would like to implement migrations for surrealdb and I think this library could be helpful.