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

[diesel_cli] There should be a way to provide backend specific migrations #336

Closed
weiznich opened this Issue May 19, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@weiznich
Contributor

weiznich commented May 19, 2016

I'm trying to support postgresql and sqlite in my application. To write the migrations for both I need to do some small changes in my migrations. For example changing postgres BIGSERIAL PRIMARY KEY into INTEGER PRIMARY KEY.

It would be great to allow writing backend specific migrations. For example in each migration directory could be a up.sql file which contains a migration that should be executed on all backends. Or there could be a up.sqlite.sql and a up.pg.sql file which contains backend specific sql for this migration.

@sgrif

This comment has been minimized.

Member

sgrif commented May 19, 2016

There is a "way" to do this right now, by supplying a migration directory manually. I'm not sure that maintaining schemas on multiple backends in the same code base is a common enough use case to warrant any support beyond that.

@toudi

This comment has been minimized.

toudi commented Sep 22, 2016

oh, I was just about to ask the same question :D I actually thought that in the SQL file there could be like a comment section or something, like:

create table ... ( whatever your default syntax is )
--- backend: sqlite ( or postgreSQL )
create table .... ( whatever the backend-specific syntax is )

so that if there is no backend: whatever section in the file, the migration could be applied from the whole file contents, but if there is, the file could be seeked to the contents of the comment

would you accept a PR of such a feature or do you believe that this shouldn't exist / and / or is too dangerous? I am actually very new when it comes to rust, but if I could help, I'd love to

@sgrif

This comment has been minimized.

Member

sgrif commented Jul 4, 2017

Closing as I don't see this being a feature that we pursue any time soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment