Permalink
Browse files

Merge pull request #2333 from OpenNMS/jira/HZN-457

HZN-457: Upgrade Liquibase to 3.x
  • Loading branch information...
j-white committed Feb 9, 2019
2 parents 431adf6 + a05defc commit d6b3b7dfb6d72da42b0a6412551c97ff0972d140
Showing with 726 additions and 1,126 deletions.
  1. +27 −0 core/schema/pom.xml
  2. +28 −19 core/schema/src/main/java/liquibase/ext/opennms/autoincrement/AddNamedAutoIncrementChange.java
  3. +32 −29 core/schema/src/main/java/liquibase/ext/opennms/createindex/CreateIndexWithWhereChange.java
  4. +26 −23 core/schema/src/main/java/liquibase/ext/opennms/createindex/CreateIndexWithWhereGenerator.java
  5. +20 −20 core/schema/src/main/java/liquibase/ext/opennms/createindex/CreateIndexWithWhereStatement.java
  6. +0 −90 core/schema/src/main/java/liquibase/ext/opennms/createtype/CreateTypeChange.java
  7. +0 −74 core/schema/src/main/java/liquibase/ext/opennms/createtype/CreateTypeGenerator.java
  8. +0 −75 core/schema/src/main/java/liquibase/ext/opennms/createtype/CreateTypeStatement.java
  9. +21 −19 ...ema/src/main/java/liquibase/ext/opennms/dropconstraint/DropForeignKeyConstraintCascadeChange.java
  10. +22 −21 .../src/main/java/liquibase/ext/opennms/dropconstraint/DropForeignKeyConstraintCascadeGenerator.java
  11. +27 −27 .../src/main/java/liquibase/ext/opennms/dropconstraint/DropForeignKeyConstraintCascadeStatement.java
  12. +53 −44 core/schema/src/main/java/liquibase/ext/opennms/setsequence/SetSequenceChange.java
  13. +50 −46 core/schema/src/main/java/liquibase/ext/opennms/setsequence/SetSequenceGenerator.java
  14. +70 −65 core/schema/src/main/java/liquibase/ext/opennms/setsequence/SetSequenceStatement.java
  15. +0 −69 core/schema/src/main/java/liquibase/ext/opennms/setsequence/TableConfig.java
  16. +0 −78 core/schema/src/main/java/org/opennms/core/schema/ExistingResourceAccessor.java
  17. +6 −18 core/schema/src/main/java/org/opennms/core/schema/Migration.java
  18. +34 −56 core/schema/src/main/java/org/opennms/core/schema/Migrator.java
  19. +0 −127 core/schema/src/main/java/org/opennms/core/schema/SpringResourceAccessor.java
  20. +4 −3 core/schema/src/main/liquibase/1.11.1/AlarmNotes.xml
  21. +2 −4 core/schema/src/main/liquibase/1.13.0/changelog.xml
  22. +39 −39 core/schema/src/main/liquibase/1.13.1/changelog.xml
  23. +2 −2 core/schema/src/main/liquibase/1.13.4/changelog.xml
  24. +2 −2 core/schema/src/main/liquibase/1.13.5/changelog.xml
  25. +9 −8 core/schema/src/main/liquibase/1.6.0/tables/alarms.xml
  26. +3 −2 core/schema/src/main/liquibase/1.6.0/tables/assets.xml
  27. +3 −2 core/schema/src/main/liquibase/1.6.0/tables/atinterface.xml
  28. +3 −2 core/schema/src/main/liquibase/1.6.0/tables/datalinkinterface.xml
  29. +3 −2 core/schema/src/main/liquibase/1.6.0/tables/demandpolls.xml
  30. +5 −4 core/schema/src/main/liquibase/1.6.0/tables/distPoller.xml
  31. +5 −4 core/schema/src/main/liquibase/1.6.0/tables/events.xml
  32. +4 −3 core/schema/src/main/liquibase/1.6.0/tables/ifservices.xml
  33. +4 −3 core/schema/src/main/liquibase/1.6.0/tables/inventory.xml
  34. +3 −2 core/schema/src/main/liquibase/1.6.0/tables/ipInterface.xml
  35. +3 −2 core/schema/src/main/liquibase/1.6.0/tables/iprouteinterface.xml
  36. +3 −2 core/schema/src/main/liquibase/1.6.0/tables/location_monitors.xml
  37. +3 −2 core/schema/src/main/liquibase/1.6.0/tables/location_specific_status_changes.xml
  38. +4 −3 core/schema/src/main/liquibase/1.6.0/tables/map.xml
  39. +4 −3 core/schema/src/main/liquibase/1.6.0/tables/node.xml
  40. +4 −3 core/schema/src/main/liquibase/1.6.0/tables/notifications.xml
  41. +5 −4 core/schema/src/main/liquibase/1.6.0/tables/outages.xml
  42. +3 −2 core/schema/src/main/liquibase/1.6.0/tables/reportlocator.xml
  43. +7 −6 core/schema/src/main/liquibase/1.6.0/tables/statisticsreport.xml
  44. +3 −2 core/schema/src/main/liquibase/1.6.0/tables/stpinterface.xml
  45. +3 −2 core/schema/src/main/liquibase/1.6.0/tables/stpnode.xml
  46. +3 −2 core/schema/src/main/liquibase/1.6.0/tables/usersnotified.xml
  47. +3 −2 core/schema/src/main/liquibase/1.6.0/tables/vlan.xml
  48. +6 −5 core/schema/src/main/liquibase/1.6.0/tables/vulnerabilities.xml
  49. +3 −2 core/schema/src/main/liquibase/1.7.1/ackd.xml
  50. +3 −2 core/schema/src/main/liquibase/1.7.1/changelog.xml
  51. +2 −1 core/schema/src/main/liquibase/1.7.10/changelog.xml
  52. +3 −1 core/schema/src/main/liquibase/1.7.10/reportcatalog.xml
  53. +27 −55 core/schema/src/main/liquibase/1.7.92/changelog.xml
  54. +6 −3 core/schema/src/main/liquibase/17.0.0/changelog.xml
  55. +3 −2 core/schema/src/main/liquibase/18.0.0/changelog.xml
  56. +6 −4 core/schema/src/main/liquibase/19.0.0/changelog.xml
  57. +2 −1 core/schema/src/main/liquibase/22.0.0/changelog.xml
  58. +2 −1 core/schema/src/main/liquibase/24.0.0/changelog.xml
  59. +9 −6 core/schema/src/main/liquibase/stored-procedures/generate_daily_series.xml
  60. +18 −1 core/test-api/db/pom.xml
  61. +21 −18 core/test-api/db/src/test/java/org/opennms/core/test/db/MigratorIT.java
  62. +6 −0 dependencies/liquibase/pom.xml
  63. +20 −0 opennms-install/pom.xml
  64. +10 −6 opennms-install/src/main/java/org/opennms/install/Installer.java
  65. +16 −0 opennms-install/src/test/resources/changelog.xml
  66. +8 −1 pom.xml
@@ -32,6 +32,17 @@
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
@@ -77,6 +88,22 @@
<version>${liquibaseVersion}</version>
<classifier>tests</classifier>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
@@ -1,8 +1,8 @@
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2011-2014 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2014 The OpenNMS Group, Inc.
* Copyright (C) 2011-2019 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2019 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
@@ -31,6 +31,9 @@
import java.util.ArrayList;
import java.util.List;

import liquibase.change.ChangeMetaData;
import liquibase.change.DatabaseChange;
import liquibase.change.DatabaseChangeNote;
import liquibase.change.core.AddAutoIncrementChange;
import liquibase.database.Database;
import liquibase.database.core.PostgresDatabase;
@@ -40,37 +43,43 @@
import liquibase.statement.core.CreateSequenceStatement;
import liquibase.statement.core.SetNullableStatement;

@DatabaseChange(name = "addAutoIncrement",
description = "Converts an existing column to be an auto-increment (a.k.a 'identity') column",
priority = ChangeMetaData.PRIORITY_DEFAULT + 1, appliesTo = "column",
databaseNotes = {@DatabaseChangeNote(
database = "sqlite", notes = "If the column type is not INTEGER it is converted to INTEGER"
)}
)
public class AddNamedAutoIncrementChange extends AddAutoIncrementChange {

private String m_sequenceName;

public AddNamedAutoIncrementChange() {
super();
setPriority(getChangeMetaData().getPriority() + 1);
public AddNamedAutoIncrementChange() {
super();
}

public String getSequenceName() {
return m_sequenceName;
return m_sequenceName;
}

public void setSequenceName(final String sequenceName) {
m_sequenceName = sequenceName;
m_sequenceName = sequenceName;
}

@Override
public SqlStatement[] generateStatements(final Database database) {
final List<SqlStatement> statements = new ArrayList<>();
final List<SqlStatement> statements = new ArrayList<>();
if (database instanceof PostgresDatabase) {
String sequenceName = m_sequenceName;
if (m_sequenceName == null) {
sequenceName = (getTableName() + "_" + getColumnName() + "_seq").toLowerCase();
statements.add(new CreateSequenceStatement(getSchemaName(), sequenceName));
}
statements.add(new SetNullableStatement(getSchemaName(), getTableName(), getColumnName(), null, false));
statements.add(new AddDefaultValueStatement(getSchemaName(), getTableName(), getColumnName(), getColumnDataType(), new DatabaseFunction("NEXTVAL('"+sequenceName+"')")));
return statements.toArray(new SqlStatement[0]);
String sequenceName = m_sequenceName;
if (m_sequenceName == null) {
sequenceName = (getTableName() + "_" + getColumnName() + "_seq").toLowerCase();
statements.add(new CreateSequenceStatement(getCatalogName(), getSchemaName(), sequenceName));
}
statements.add(new SetNullableStatement(getCatalogName(), getSchemaName(), getTableName(), getColumnName(), null, false));
statements.add(new AddDefaultValueStatement(getCatalogName(), getSchemaName(), getTableName(), getColumnName(), getColumnDataType(), new DatabaseFunction("NEXTVAL('"+sequenceName+"')")));
return statements.toArray(new SqlStatement[0]);
} else {
return super.generateStatements(database);
return super.generateStatements(database);
}
}

@@ -1,8 +1,8 @@
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2011-2014 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2014 The OpenNMS Group, Inc.
* Copyright (C) 2011-2019 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2019 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
@@ -28,41 +28,44 @@

package liquibase.ext.opennms.createindex;

import liquibase.change.ChangeMetaData;
import liquibase.change.DatabaseChange;
import liquibase.database.Database;
import liquibase.logging.LogFactory;
import liquibase.logging.LogService;
import liquibase.logging.Logger;
import liquibase.statement.SqlStatement;
import liquibase.statement.core.CreateIndexStatement;

@DatabaseChange(name="createIndex", description = "Creates an index on an existing column or set of columns.", priority = ChangeMetaData.PRIORITY_DEFAULT + 1, appliesTo = "index")
public class CreateIndexWithWhereChange extends liquibase.change.core.CreateIndexChange {
private static final Logger LOG = LogService.getLog(CreateIndexWithWhereChange.class);
private String m_where;

private String m_where;
public CreateIndexWithWhereChange() {
super();
}

public String getWhere() {
return m_where;
}

public void setWhere(final String where) {
m_where = where;
}

@Override
public SqlStatement[] generateStatements(final Database database) {
final SqlStatement[] superStatements = super.generateStatements(database);
if (m_where == null) return superStatements;

public CreateIndexWithWhereChange() {
super();
setPriority(getChangeMetaData().getPriority() + 1);
}
if (superStatements.length != 1) {
LOG.warning("expected 1 create index statement, but got " + superStatements.length);
return superStatements;
}

public String getWhere() {
return m_where;
}

public void setWhere(final String where) {
m_where = where;
}

@Override
public SqlStatement[] generateStatements(final Database database) {
final SqlStatement[] superStatements = super.generateStatements(database);
if (m_where == null) return superStatements;

if (superStatements.length != 1) {
LogFactory.getLogger().warning("expected 1 create index statement, but got " + superStatements.length);
return superStatements;
}

return new SqlStatement[]{
new CreateIndexWithWhereStatement((CreateIndexStatement)superStatements[0], m_where)
};
return new SqlStatement[]{
new CreateIndexWithWhereStatement((CreateIndexStatement)superStatements[0], m_where)
};
}

}
@@ -1,8 +1,8 @@
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2011-2014 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2014 The OpenNMS Group, Inc.
* Copyright (C) 2011-2019 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2019 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
@@ -29,38 +29,41 @@
package liquibase.ext.opennms.createindex;

import liquibase.database.Database;
import liquibase.database.structure.DatabaseObject;
import liquibase.logging.LogFactory;
import liquibase.logging.LogService;
import liquibase.logging.Logger;
import liquibase.sql.Sql;
import liquibase.sql.UnparsedSql;
import liquibase.sqlgenerator.SqlGeneratorChain;
import liquibase.sqlgenerator.core.CreateIndexGenerator;
import liquibase.statement.core.CreateIndexStatement;
import liquibase.structure.DatabaseObject;

public class CreateIndexWithWhereGenerator extends CreateIndexGenerator {
private static final Logger LOG = LogService.getLog(CreateIndexWithWhereGenerator.class);

@Override
public int getPriority() {
return super.getPriority() + 1;
}
@Override
public int getPriority() {
return super.getPriority() + 1;
}

@Override
@Override
@SuppressWarnings("rawtypes")
public Sql[] generateSql(final CreateIndexStatement statement, final Database database, final SqlGeneratorChain sqlGeneratorChain) {
final Sql[] superSql = super.generateSql(statement, database, sqlGeneratorChain);
final Sql[] superSql = super.generateSql(statement, database, sqlGeneratorChain);

if (statement instanceof CreateIndexWithWhereStatement) {
if (superSql.length != 1) {
LOG.warning("expected 1 create index statement, but got " + superSql.length);
return superSql;
}

if (statement instanceof CreateIndexWithWhereStatement) {
if (superSql.length != 1) {
LogFactory.getLogger().warning("expected 1 create index statement, but got " + superSql.length);
return superSql;
}

return new Sql[] {
new UnparsedSql(superSql[0].toSql() + " WHERE " + ((CreateIndexWithWhereStatement)statement).getWhere(),
superSql[0].getEndDelimiter(), superSql[0].getAffectedDatabaseObjects().toArray(new DatabaseObject[0]))
};
} else {
return superSql;
}
return new Sql[] {
new UnparsedSql(superSql[0].toSql() + " WHERE " + ((CreateIndexWithWhereStatement)statement).getWhere(),
superSql[0].getEndDelimiter(), superSql[0].getAffectedDatabaseObjects().toArray(new DatabaseObject[0]))
};
} else {
return superSql;
}
}

}
@@ -1,8 +1,8 @@
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2011-2014 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2014 The OpenNMS Group, Inc.
* Copyright (C) 2011-2019 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2019 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
@@ -28,29 +28,29 @@

package liquibase.ext.opennms.createindex;

import liquibase.change.AddColumnConfig;
import liquibase.statement.SqlStatement;
import liquibase.statement.core.CreateIndexStatement;

public class CreateIndexWithWhereStatement extends CreateIndexStatement
implements SqlStatement {
public class CreateIndexWithWhereStatement extends CreateIndexStatement implements SqlStatement {

private String m_where;
private String m_where;

public CreateIndexWithWhereStatement(final String indexName, final String tableSchemaName, final String tableName, final Boolean isUnique, final String associatedWith, final String... columns) {
super(indexName, tableSchemaName, tableName, isUnique, associatedWith, columns);
}
public CreateIndexWithWhereStatement(final String indexName, final String tableCatalogName, final String tableSchemaName, final String tableName, final Boolean isUnique, final String associatedWith, final AddColumnConfig... columns) {
super(indexName, tableCatalogName, tableSchemaName, tableName, isUnique, associatedWith, columns);
}

public CreateIndexWithWhereStatement(final CreateIndexStatement statement, final String where) {
this(statement.getIndexName(), statement.getTableSchemaName(), statement.getTableName(), statement.isUnique(), statement.getAssociatedWith(), statement.getColumns());
m_where = where;
}
public CreateIndexWithWhereStatement(final CreateIndexStatement statement, final String where) {
this(statement.getIndexName(), statement.getTableCatalogName(), statement.getTableSchemaName(), statement.getTableName(), statement.isUnique(), statement.getAssociatedWith(), statement.getColumns());
m_where = where;
}

public String getWhere() {
return m_where;
}
public CreateIndexWithWhereStatement setWhere(final String where) {
m_where = where;
return this;
}
public String getWhere() {
return m_where;
}

public CreateIndexWithWhereStatement setWhere(final String where) {
m_where = where;
return this;
}
}
Oops, something went wrong.

0 comments on commit d6b3b7d

Please sign in to comment.