Support running additional changelogs at the end
In case you want to add your own custom stuff or change drops or something else.
This commit is contained in:
@@ -9,8 +9,16 @@ import tools.DatabaseConnection;
|
|||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Apply changes to the database so that the server and database work in harmony.
|
||||||
|
*
|
||||||
|
* @author Ponk
|
||||||
|
*/
|
||||||
public class DatabaseMigrations {
|
public class DatabaseMigrations {
|
||||||
|
private static final String ROOT_CHANGELOG_FILE = "db/changelog-root.xml";
|
||||||
|
|
||||||
public static void runDatabaseMigrations() {
|
public static void runDatabaseMigrations() {
|
||||||
suppressLiquibaseLogs();
|
suppressLiquibaseLogs();
|
||||||
@@ -18,14 +26,14 @@ public class DatabaseMigrations {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void suppressLiquibaseLogs() {
|
private static void suppressLiquibaseLogs() {
|
||||||
java.util.logging.Logger liquibaseLogger = java.util.logging.Logger.getLogger("liquibase");
|
Logger liquibaseLogger = Logger.getLogger("liquibase");
|
||||||
liquibaseLogger.setLevel(java.util.logging.Level.WARNING);
|
liquibaseLogger.setLevel(Level.WARNING);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void runLiquibaseUpdate() {
|
private static void runLiquibaseUpdate() {
|
||||||
try (Connection connection = DatabaseConnection.getConnection()) {
|
try (Connection connection = DatabaseConnection.getConnection()) {
|
||||||
liquibase.database.DatabaseConnection databaseConnection = new JdbcConnection(connection);
|
liquibase.database.DatabaseConnection databaseConnection = new JdbcConnection(connection);
|
||||||
Liquibase liquibase = new Liquibase("db/changelog-root.xml", new ClassLoaderResourceAccessor(),
|
Liquibase liquibase = new Liquibase(ROOT_CHANGELOG_FILE, new ClassLoaderResourceAccessor(),
|
||||||
databaseConnection);
|
databaseConnection);
|
||||||
liquibase.setShowSummaryOutput(UpdateSummaryOutputEnum.LOG);
|
liquibase.setShowSummaryOutput(UpdateSummaryOutputEnum.LOG);
|
||||||
liquibase.update();
|
liquibase.update();
|
||||||
|
|||||||
@@ -5,7 +5,11 @@
|
|||||||
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
|
||||||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
|
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-latest.xsd">
|
||||||
|
|
||||||
<include file="/db/changelog-tables.xml"/>
|
<include file="changelog-tables.xml" relativeToChangelogFile="true"/>
|
||||||
<include file="/db/changelog-data.xml"/>
|
<include file="changelog-data.xml" relativeToChangelogFile="true"/>
|
||||||
|
|
||||||
|
<!-- If you have any additional changesets you would like to run at the end, create an "extensions" directory and put them in there. -->
|
||||||
|
<!-- All changesets will run in alphanumeric order based on their filename. Read Liquibase documentation on "includeAll" for more info. -->
|
||||||
|
<includeAll path="extensions" relativeToChangelogFile="true" errorIfMissingOrEmpty="false"/>
|
||||||
|
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
Reference in New Issue
Block a user