Skip to content

Instantly share code, notes, and snippets.

@xconnecting
Created May 27, 2013 01:13
Show Gist options
  • Save xconnecting/5654671 to your computer and use it in GitHub Desktop.
Save xconnecting/5654671 to your computer and use it in GitHub Desktop.
[Groovy] Flyway Groovy Migration
package db.migration;
import com.googlecode.flyway.core.api.migration.jdbc.JdbcMigration;
import java.sql.Connection;
import java.sql.PreparedStatement;
/**
* Example of a Groovy-based migration.
*/
public class V1_0__Create_person_table implements JdbcMigration {
public void migrate(Connection connection) throws Exception {
def sql = """\
create table PERSON (
ID int not null,
NAME varchar(100) not null
);"""
PreparedStatement statement =
connection.prepareStatement(sql)
try {
statement.execute()
} finally {
statement.close()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment