Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAlternative Migration System #1397
Comments
This comment has been minimized.
|
In theory this should be already be possible with the current code. |
This comment has been minimized.
|
Oh I didn't realize there already was a Migration trait, thanks for pointing that out. The point of making This also would make it possible to implement backend-specific migrations to support multiple backends. But otherwise, yeah, all that would be needed is a macro that takes an array of migrations and generates the code for running them, and potentially an extension to diesel-cli for generating migrations. |
This comment has been minimized.
sanmai-NL
commented
Dec 15, 2017
|
@weiznich: https://docs.rs/migrations_internals/1.0.0-beta1/macro.embed_migrations.html on https://docs.rs/migrations_internals/1.0.0-beta1/migrations_internals/ does not work. https://docs.diesel.rs/diesel/macro.embed_migrations.html, found on Google, also doesn’t. Do you know the correct docs link? |
This comment has been minimized.
This comment has been minimized.
|
This has come up before, and I don't think this issue brings up anything new. I've said in the past that for us to consider Rust migrations, there would need to be a really compelling use case. So far the only real use case that's been raised is "you can sometimes get I have made sure that the code is structured so alternative migration forms can be added in the future, and we will continue to make that the case. Since this doesn't raise any new use cases that haven't been discussed, and there's nothing actionable here, I'm going to close this issue. See #980, #336, #10, and gitter history for past discussions on this topic. |
sgrif
closed this
Dec 16, 2017
This comment has been minimized.
dbkaplun
commented
Mar 30, 2018
|
This is the one feature I look for that weaker ORMs do not implement: programmatic migrations. |
This comment has been minimized.
|
@sgrif just for the record, to me this request was not about migrations declared as code. BUT there are situations where you need to migrate the actual data, not the database schema, and which can't easily be done with SQL. Potentially with scripting the database a la pl/pgsql but it's usually much easier with regular application code. This would be the prime use case for me. |
This comment has been minimized.
|
@theduke I agree with you that it is a reasonable use case. I just don't think it's one that fits into Diesel. I've architected our migration infrastructure to make it easy for third party crates to come in with new functionality (see the barrel feature for an example). |
theduke commentedDec 15, 2017
The current migration system is quite limiting, because you often run into situations where just SQL is not enough to actually migrate the data in the way you need to.
A lot of similar libraries have a way of declaring migrations as code, and I'd love to see a similar design for diesel.
Something like:
The
clicould have an auto-generator for migrations that would just put them inside a specified module to make it just as convenient as it is now.This could easily be implemented out of tree of course, and I'll probably do so if neccessary.
But having it in diesel-cli would be very nice, so I wanted to see if this is something the maintainers could see being included.