Skip to content
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

If statement in migration scripts? #20

Closed
Pacane opened this issue Jun 9, 2015 · 5 comments
Closed

If statement in migration scripts? #20

Pacane opened this issue Jun 9, 2015 · 5 comments

Comments

@Pacane
Copy link

Pacane commented Jun 9, 2015

Is there any way to use some conditional logic in a migration script? I have 2 databases (hsqlb and postgres) and it seems sometimes their syntax differ. I'd like to run specific parts of migration scripts based on the selected environment.

@h3adache
Copy link
Member

There is not. There's no plans to support this. Is this something that you can handle with different modules?

@hazendaz
Copy link
Member

hazendaz commented Apr 9, 2016

@Pacane Did you get around this issue? Can this be closed?

@tohagan
Copy link

tohagan commented Oct 27, 2016

You might want to have a look at alternative tools that can support database neutral migrations.

One I know of FluentMigrator (you write C# migrations and it generates SQL for the target database).
Supported database are: https://github.com/schambers/fluentmigrator/wiki/Supported-Databases .
There might be a similar Java tool.

You may still need to SQL platform specific code for Stored procs, Functions, Triggers etc. I wrote an extension for FluentMigrator to assist doing this in a fork. It allows you to selectively run some scripts for different platforms based on SQL file/folder naming conventions.

@h3adache
Copy link
Member

Sorry for the slow response. You can do this by combining the scriptpath and env variables as an alternative. It sounds like you already have environments setup for both db vendors, you can setup script paths separately for them as well.
This feature was added a while back but isn't documented in the help/online docs I'm afraid. I'll add a ticket for that

@h3adache
Copy link
Member

#64 was created

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants