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

SQL Server migration batch terminator as first statement gives empty query error #1838

Closed
mpapetti opened this issue Nov 23, 2017 · 2 comments
Closed

Comments

@mpapetti
Copy link

@mpapetti mpapetti commented Nov 23, 2017

What version of Flyway are you using?

4.2.0

Which client are you using? (Command-line, Java API, Maven plugin, Gradle plugin, SBT plugin, ANT tasks)

CLI

What database are you using (type & version)?

SQL Server 2016

What operating system are you using?

Amazon linux

What did you do?

(Please include the content causing the issue, any relevant configuration settings, and the command you ran)

Tried to run a migration with the following as the first few lines:

/*
 some comment
*/
GO
SET NOCOUNT ON
SET NOEXEC OFF
SET ARITHABORT ON

I ran flyway -url='mydburl/mydb' -locations='mylocation' migrate

What did you expect to see?

I expected the migration to run successfully

What did you see instead?

The migration ran fine when I removed GO. When I put GO as the first line of a migration, it will fail with the error below. Is it possible for flyway to ignore this line if no query exists before it? I suggest a simple regex to identify:

  • If a migration's GO or batch terminator (or configured terminator) has an actual query preceding it or just some comments
  • Based on previous, ignore the batch terminator if comments are found or run the query if it is found
SQL State  : HY000
Error Code : 0
Message    : The SQL statement must not be null or empty.
Location   : myMigration.sql 
Line       : 4
Statement  : 

Thanks!

@axelfontaine
Copy link
Contributor

@axelfontaine axelfontaine commented Dec 18, 2017

This is now working. (Make sure to use the newly bundled MS driver)

axelfontaine added a commit to flyway/flywaydb.org that referenced this issue Dec 18, 2017
@mpapetti
Copy link
Author

@mpapetti mpapetti commented Dec 18, 2017

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

Successfully merging a pull request may close this issue.

None yet
2 participants