|
|
@@ -41,6 +41,7 @@ import static org.apache.commons.lang3.RandomStringUtils.randomAlphanumeric; |
|
|
|
import static org.cobbzilla.util.daemon.ZillaRuntime.*; |
|
|
|
import static org.cobbzilla.util.io.FileUtil.abs; |
|
|
|
import static org.cobbzilla.wizard.server.config.PgRestServerConfiguration.ENV_PGPASSWORD; |
|
|
|
import static org.cobbzilla.wizard.server.listener.FlywayMigrationListener.getFlywayTableName; |
|
|
|
|
|
|
|
@Service @Slf4j |
|
|
|
public class DatabaseFilterService { |
|
|
@@ -87,6 +88,19 @@ public class DatabaseFilterService { |
|
|
|
if (!schemaResult.isZeroExitStatus()) return die("copyDatabase: error populating schema for "+dbName+": "+schemaResult); |
|
|
|
} |
|
|
|
|
|
|
|
// Copy full flyway schema history to new database |
|
|
|
final var flywayHistory = new File(temp, "flyway.sql"); |
|
|
|
log.info("copyDatabase: dumping flyway schema history data for current database to file: " |
|
|
|
+ abs(flywayHistory)); |
|
|
|
try (InputStream in = new FileInputStream(configuration.pgDumpDataOnly(flywayHistory, |
|
|
|
getFlywayTableName()))) { |
|
|
|
log.info("copyDatabase: writing dumped flyway history data to new database " + dbName); |
|
|
|
final var result = pgExec("psql", dbName, in, null); |
|
|
|
if (!result.isZeroExitStatus()) { |
|
|
|
return die("copyDatabase: error populating flyway history data for " + dbName + ": " + result); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
log.info("copyDatabase: copying/filtering data into new database: "+dbName+", "+planApps.size()+" apps enabled") ; |
|
|
|
final int port = PortPicker.pickOrDie(); |
|
|
|
|
|
|
|