use of org.flywaydb.core.internal.dbsupport.SqlStatement in project killbill by killbill.
the class Migrator method main.
/**
* Main method.
*
* @param args The command-line arguments.
*/
public static void main(final String[] args) {
final Level logLevel = getLogLevel(args);
initLogging(logLevel);
try {
if (isPrintVersionAndExit(args)) {
printVersion();
System.exit(0);
}
final List<String> operations = determineOperations(args);
if (operations.isEmpty()) {
printUsage();
return;
}
final Properties properties = new Properties();
initializeDefaults(properties);
loadConfiguration(properties, args);
overrideConfiguration(properties, args);
dumpConfiguration(properties);
loadJdbcDrivers();
loadJavaMigrationsFromJarDirs(properties);
final List<SqlStatement> sqlStatements = new LinkedList<SqlStatement>();
final FlywayWithDryRun flyway = new FlywayWithDryRun(sqlStatements);
filterProperties(properties);
flyway.configure(properties);
for (final String operation : operations) {
executeOperation(flyway, operation, sqlStatements);
}
} catch (final Exception e) {
if (logLevel == Level.DEBUG) {
LOG.error("Unexpected error", e);
} else {
if (e instanceof FlywayException) {
LOG.error(e.getMessage());
} else {
LOG.error(e.toString());
}
}
System.exit(1);
}
}
use of org.flywaydb.core.internal.dbsupport.SqlStatement in project flyway by flyway.
the class MySQLSqlScriptSmallTest method unquotedMultiLineCommentDirective.
@Test
public void unquotedMultiLineCommentDirective() throws Exception {
String source = "INSERT INTO tablename VALUES ('a','b');\n" + "/*!50001 CREATE TABLE `viewname` (\n" + "`id` int(10) unsigned,\n" + "`name` varchar(10)\n" + ") ENGINE=MyISAM */;\n" + "INSERT INTO tablename VALUES ('a','b');";
SqlScript sqlScript = new SqlScript(source, new MySQLDbSupport(null));
List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
assertEquals(3, sqlStatements.size());
assertEquals(1, sqlStatements.get(0).getLineNumber());
assertEquals(2, sqlStatements.get(1).getLineNumber());
assertEquals(6, sqlStatements.get(2).getLineNumber());
}
use of org.flywaydb.core.internal.dbsupport.SqlStatement in project flyway by flyway.
the class EnterpriseDBSqlScriptSmallTest method parseSqlStatements.
@Test
public void parseSqlStatements() throws Exception {
String source = new ClassPathResource("migration/dbsupport/enterprisedb/sql/placeholders/V1__Placeholders.sql", Thread.currentThread().getContextClassLoader()).loadAsString("UTF-8");
SqlScript sqlScript = new SqlScript(source, new EnterpriseDBDbSupport(null));
List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
assertEquals(3, sqlStatements.size());
assertEquals(18, sqlStatements.get(0).getLineNumber());
assertEquals(27, sqlStatements.get(1).getLineNumber());
assertEquals(32, sqlStatements.get(2).getLineNumber());
assertEquals("COMMIT", sqlStatements.get(2).getSql());
}
use of org.flywaydb.core.internal.dbsupport.SqlStatement in project flyway by flyway.
the class EnterpriseDBSqlScriptSmallTest method parseSqlStatementsWithInlineCommentsInsidePlSqlBlocks.
@Test
public void parseSqlStatementsWithInlineCommentsInsidePlSqlBlocks() throws Exception {
String source = new ClassPathResource("migration/dbsupport/enterprisedb/sql/function/V2__FunctionWithConditionals.sql", Thread.currentThread().getContextClassLoader()).loadAsString("UTF-8");
SqlScript sqlScript = new SqlScript(source, new EnterpriseDBDbSupport(null));
List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
assertEquals(1, sqlStatements.size());
assertEquals(18, sqlStatements.get(0).getLineNumber());
assertTrue(sqlStatements.get(0).getSql().contains("/* for the rich */"));
}
use of org.flywaydb.core.internal.dbsupport.SqlStatement in project flyway by flyway.
the class EnterpriseDBSqlScriptSmallTest method parseFunctionsAndProcedures.
@Test
public void parseFunctionsAndProcedures() throws Exception {
String source = new ClassPathResource("migration/dbsupport/enterprisedb/sql/function/V1__Function.sql", Thread.currentThread().getContextClassLoader()).loadAsString("UTF-8");
SqlScript sqlScript = new SqlScript(source, new EnterpriseDBDbSupport(null));
List<SqlStatement> sqlStatements = sqlScript.getSqlStatements();
assertEquals(5, sqlStatements.size());
assertEquals(18, sqlStatements.get(0).getLineNumber());
assertEquals(33, sqlStatements.get(1).getLineNumber());
assertEquals(41, sqlStatements.get(2).getLineNumber());
assertEquals(43, sqlStatements.get(3).getLineNumber());
assertEquals(51, sqlStatements.get(4).getLineNumber());
assertEquals("COMMIT", sqlStatements.get(4).getSql());
}
Aggregations