use of org.eclipse.che.core.db.schema.SchemaInitializer in project che by eclipse.
the class FlywaySchemaInitializerTest method initializesSchemaWhenDatabaseIsEmpty.
@Test
public void initializesSchemaWhenDatabaseIsEmpty() throws Exception {
createScript("1.0/1__init.sql", "CREATE TABLE test (id INT, text TEXT, PRIMARY KEY (id));");
createScript("1.0/2__add_data.sql", "INSERT INTO test VALUES(1, 'test1');" + "INSERT INTO test VALUES(2, 'test2');" + "INSERT INTO test VALUES(3, 'test3');");
createScript("2.0/1__add_more_data.sql", "INSERT INTO test VALUES(4, 'test4');");
createScript("2.0/postgresql/1__add_more_data.sql", "INSERT INTO test VALUES(4, 'postgresql-data');");
final SchemaInitializer initializer = FlywayInitializerBuilder.from(dataSource).build();
initializer.init();
assertEquals(queryEntities(), Sets.newHashSet(new TestEntity(1, "test1"), new TestEntity(2, "test2"), new TestEntity(3, "test3"), new TestEntity(4, "test4")));
// second init must do nothing, so there are no conflicts
initializer.init();
}
Aggregations