Re : liquibase + h2
Re : rollbacks not working if Spring starts them even if runInTransaction=false
Re : Validation and Output
- /**
- * CustomBuildCheck Precondition
- * <customPrecondition className="nl.tele2.bos.liquibase.custom.preconditions.CustomBuildCheck">
- * <param name="sql" value="Select * from ...;"/>
- * <param name="expectedResult" value="0"/>
- * </customPrecondition>
- *
- * @author Enric Ballo (enric.ballo@tele2.com)
- * @since Oct 24, 2014
- */
- @Getter
- @Setter
- public class CustomBuildCheck implements CustomPrecondition {
-
- private static final String LAST_DDL_TIME = "LAST_DDL_TIME";
-
- /** Liquibase logger */
- private final Logger logger = LogFactory.getInstance().getLog("liquibase");
-
- /** the sql to execute */
- private String sql;
-
- /** the expected result */
- private String expectedResult;
-
- @SuppressWarnings("rawtypes")
- @Override
- public void check(final Database database) throws CustomPreconditionFailedException, CustomPreconditionErrorException {
-
- try {
- logger.debug("CustomBuildCheck is executed...");
-
- final List<Map<String, ?>> resultQuery =
- ExecutorService.getInstance().getExecutor(database).queryForList(
- new RawSqlStatement(getSql().replaceFirst(";$", "")));
-
- if (resultQuery == null) {
- throw new CustomPreconditionFailedException("No rows returned from SQL Precondition");
- }
-
- final int size = resultQuery.size();
- logger.debug("result is :" + size);
- logger.debug("expected result is :" + expectedResult);
- final Integer resultInteger = new Integer(size);
- final Integer expectIntegerResult = new Integer(expectedResult);
-
- if (!expectIntegerResult.equals(resultInteger)) {
-
- logger.debug("We have some errors! displaying the result");
-
- final StringBuilder invalidObject = new StringBuilder();
- int counter = 1;
- for (final Map<String, ?> map : resultQuery) {
-
- invalidObject.append(" " + counter + " ) ");
-
- for (final Map.Entry entry : map.entrySet()) {
- invalidObject.append(entry.getValue());
- //Avoid the last -
- if (!entry.getKey().equals(LAST_DDL_TIME)) {
- invalidObject.append(" - ");
- }
-
- }
-
- invalidObject.append("\n");
- counter++;
- }
-
- final StringBuilder message = new StringBuilder();
- message.append("\n");
- message.append("\n");
- message.append("\n");
- message.append("--------------------------------------------------------------------------------------------- \n");
- message.append(" ERROR - There are " + size + " invalid Objects in the Database \n");
- message.append("--------------------------------------------------------------------------------------------- \n");
- message.append(" OWNER - OBJECT NAME - STATUS - LAST DDL TIME \n");
- message.append("\n");
- message.append(invalidObject.toString());
- message.append("\n");
- message.append("--------------------------------------------------------------------------------------------- \n");
- message.append("\n");
- message.append("\n");
-
- throw new CustomPreconditionFailedException(message.toString());
- }
-
- } catch (final DatabaseException e) {
- throw new CustomPreconditionFailedException(e.getMessage());
- }
- }
-
- }
- <changeSet id="dataBaseCheck_v2" author="e-ballo" runAlways="true">
- <preConditions onFail="HALT">
- <customPrecondition
- className="nl.tele2.bos.liquibase.custom.preconditions.CustomBuildCheck">
- <param name="sql" value="SELECT alo.owner
- ,alo.object_name
- ,alo.status
- ,alo.last_ddl_time
- FROM all_objects alo
- WHERE status = 'INVALID'
- AND alo.owner in ('BOS_RELEASE','BIL','BLIS','CBSMIG','COJO','CMD_AGENT','CIN','NOPA','ORC','PRV','SEC','TIPI_OWNER','TT','ZON')
- AND alo.OBJECT_NAME not like 'TST%'
- AND alo.OBJECT_NAME not like 'TEST%'
- AND ALO.OBJECT_NAME <> 'ZON_ORBIT_LOG_PCK'
- AND ALO.OBJECT_NAME <> 'ZON_TESTING_PCK'
- AND ALO.OBJECT_NAME <> 'ZON_MONITORING_PCK'
- ORDER BY alo.owner, alo.object_name;"/>
- <param name="expectedResult" value="0" />
- </customPrecondition>
- </preConditions>
- </changeSet>
Re : Validation and Output
Error executing SQL --rollback drop table test: Invalid SQL type: sqlKind = UNINITIALIZED
Re : Compability issues between master of liquibase-core and liquibase-hibernate
junit compile scope
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope>
</dependency>
Is it really necessary to use the compile scope?
Re : rollbacks not working if Spring starts them even if runInTransaction=false
Re : Error executing SQL --rollback drop table test: Invalid SQL type: sqlKind = UNINITIALIZED
Re : junit compile scope
Re : Liquibase 2.0.5 does not seem to commit between changesets against MySQL 5.5
creates a new table with foreign key constraints and one or more other ChangeSet(s) that use dropAllForeignKeyConstraints tag to drop all foreing key constraints from that same table.
But the problem is not caused by MySQL or missing database commit, but due to the way the class
liquibase.change.core.DropAllForeignKeyConstraintsChange is implemented.
On the validation stage, liquibase.change.core.DropAllForeignKeyConstraintsChange.generateStatements(Database)
method is called, and here there are some lazy initialization statements for the private List attribute childDropChanges: on this stage both the new table has not been created yet and private attribute childDropChanges is not initialized yet, so the private method generateChildren(Database database) is called, but it doesn't find any foreign key constraint defined for the baseTableName declared (the table doesn't exist yet!), so the childDropChanges List attribute is initialized, empty...
When run stage arise, the List attribute childDropChanges of DropAllForeignKeyConstraintsChange has been
inizialized, so the lazy initialization code inside generateStatements(Database) is skipped, leaving the
List childDropChanges empty, even if, in the mean time, other ChangeSet created the table and its foreign key
constraints that one expects should be dropped!
So the change run successfully with an empty list of constraint to drop, leaving the table unchanged!
I'm stuck to the 2.0.5 version due to incompatibility of new versions of Liquibase with some extensions of mine: any solutions to suggest?
Many thanks in advance
Regards
Roberto
MySQL 5.6 keywords `partition' not quoted as a column name
I am trying to upgrade my liquibase to 3.3.0
If the column contains a keyword, such as "PARTITION". the migration fails.
e.g.
the generated SQL DDL contains: PARTITION VARCHAR(20) NOT
NULL
because there is a change set about creating a table with a
column called key.
I found the similar closed bug https://liquibase.jira.com/browse/CORE-1478. It is fixed for word "key". I have the same problem with "PARTITION".
My change set is :
<changeSet id="create table TABLE_1 " author="tomcat">
<createTable tableName=" TABLE_1 ">
<column name="PARTITION" type="VARCHAR(64)"/>
<column name="NAME" type="VARCHAR(255)"/>
</createTable>
</changeSet>
Re : Error executing SQL --rollback drop table test: Invalid SQL type: sqlKind = UNINITIALIZED
Re : Formatted SQL with a comment.
Labels vs. contexts in 3.3.0
What is the ResourceAccessor#list() method used for?
Best,