in service/src/main/java/org/apache/fineract/cn/accounting/service/internal/command/handler/MigrationCommandHandler.java [84:168]
public String initialize(final InitializeServiceCommand initializeServiceCommand) {
final Flyway flyway = this.flywayFactoryBean.create(this.dataSource);
final MigrationInfoService migrationInfoService = flyway.info();
final List<MigrationInfo> migrationInfoList = Arrays.asList(migrationInfoService.applied());
final boolean shouldMigrateLedgerTotals = migrationInfoList
.stream()
.noneMatch(migrationInfo -> migrationInfo.getVersion().getVersion().equals("9"));
flyway.migrate();
final String versionNumber = "1";
final CassandraJourneyRoute initialRoute = CassandraJourneyRoute
.plan("1")
.addWaypoint(
SchemaBuilder
.createType("thoth_debtor")
.addColumn("account_number", DataType.text())
.addColumn("amount", DataType.cdouble())
.buildInternal())
.addWaypoint(
SchemaBuilder
.createType("thoth_creditor")
.addColumn("account_number", DataType.text())
.addColumn("amount", DataType.cdouble())
.buildInternal())
.addWaypoint(
SchemaBuilder
.createTable("thoth_journal_entries")
.addPartitionKey("date_bucket", DataType.text())
.addClusteringColumn("transaction_identifier", DataType.text())
.addColumn("transaction_date", DataType.timestamp())
.addColumn("clerk", DataType.text())
.addColumn("note", DataType.text())
.addUDTSetColumn("debtors", SchemaBuilder.frozen("thoth_debtor"))
.addUDTSetColumn("creditors", SchemaBuilder.frozen("thoth_creditor"))
.addColumn("state", DataType.text())
.addColumn("message", DataType.text())
.buildInternal())
.addWaypoint(SchemaBuilder
.createTable("thoth_journal_entry_lookup")
.addPartitionKey("transaction_identifier", DataType.text())
.addColumn("date_bucket", DataType.text())
.buildInternal())
.build();
final CassandraJourneyRoute updateRouteVersion2 = CassandraJourneyRoute
.plan("2")
.addWaypoint(
SchemaBuilder
.alterTable("thoth_journal_entries")
.addColumn("transaction_type").type(DataType.text())
.getQueryString()
)
.build();
final CassandraJourneyRoute updateRouteVersion3 = CassandraJourneyRoute
.plan("3")
.addWaypoint(
SchemaBuilder
.alterTable("thoth_journal_entries")
.addColumn("created_by").type(DataType.text())
.getQueryString()
)
.addWaypoint(
SchemaBuilder
.alterTable("thoth_journal_entries")
.addColumn("created_on").type(DataType.timestamp())
.getQueryString()
)
.build();
final CassandraJourney cassandraJourney = this.cassandraJourneyFactory.create(this.cassandraSessionProvider);
cassandraJourney.start(initialRoute);
cassandraJourney.start(updateRouteVersion2);
cassandraJourney.start(updateRouteVersion3);
if (shouldMigrateLedgerTotals) {
this.migrateLedgerTotals();
}
return versionNumber;
}