Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Upgrade to Liquibase 2.0
  • Loading branch information
Carlos Munoz committed Mar 21, 2012
1 parent b3fc29c commit 27cdcab
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 54 deletions.
29 changes: 17 additions & 12 deletions server/zanata-war/pom.xml
Expand Up @@ -1277,20 +1277,25 @@
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
</dependency>

<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>modify-column</artifactId>
</dependency>

<!-- openid4java -->
<dependency>
<groupId>org.htmlparser</groupId>
<artifactId>htmlparser</artifactId>
<version>1.6</version>
<exclusions>
<!-- htmlparser tries to bring in java.home/lib/tools.jar -->
<exclusion>
<artifactId>tools</artifactId>
<groupId>com.sun</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.htmlparser</groupId>
<artifactId>htmlparser</artifactId>
<version>1.6</version>
<exclusions>
<!-- htmlparser tries to bring in java.home/lib/tools.jar -->
<exclusion>
<artifactId>tools</artifactId>
<groupId>com.sun</groupId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.openid4java</groupId>
Expand Down
Expand Up @@ -5,17 +5,17 @@
import java.sql.Statement;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Logger;

import liquibase.FileOpener;
import liquibase.change.custom.CustomTaskChange;
import liquibase.database.Database;
import liquibase.database.DatabaseConnection;
import liquibase.database.jvm.JdbcConnection;
import liquibase.exception.CustomChangeException;
import liquibase.exception.InvalidChangeDefinitionException;
import liquibase.exception.DatabaseException;
import liquibase.exception.SetupException;
import liquibase.exception.UnsupportedChangeException;
import liquibase.log.LogFactory;
import liquibase.exception.ValidationErrors;
import liquibase.logging.LogFactory;
import liquibase.logging.Logger;
import liquibase.resource.ResourceAccessor;

import org.zanata.util.OkapiUtil;

Expand All @@ -34,19 +34,20 @@ public void setUp() throws SetupException
}

@Override
public void setFileOpener(FileOpener fileOpener)
public void setFileOpener(ResourceAccessor accessor)
{
}

@Override
public void validate(Database database) throws InvalidChangeDefinitionException
public ValidationErrors validate(Database database)
{
return new ValidationErrors();
}

@Override
public void execute(Database database) throws CustomChangeException, UnsupportedChangeException
public void execute(Database database) throws CustomChangeException
{
DatabaseConnection conn = database.getConnection();
JdbcConnection conn = (JdbcConnection)database.getConnection();
try
{
Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE);
Expand Down Expand Up @@ -96,6 +97,10 @@ public void execute(Database database) throws CustomChangeException, Unsupported
{
throw new CustomChangeException(e);
}
catch (DatabaseException e)
{
throw new CustomChangeException(e);
}
finally
{
// conn.close(); ?
Expand Down
@@ -1,5 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<changeSet author="flies" id="mysql_baseline" dbms="mysql">
<preConditions onFail="MARK_RAN">
Expand Down
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<changeSet author="sflaniga@redhat.com" id="1">

<validCheckSum>cfb156591044f08e333d7ca2d5638db3</validCheckSum>
Expand Down Expand Up @@ -41,11 +47,11 @@

<comment>calculate existing word counts and enable non-null constraint on HTextFlow</comment>
<customChange class="org.zanata.liquibase.custom.CountWordsInHTextFlow" />
<modifyColumn tableName="HTextFlow">
<ext:modifyColumn tableName="HTextFlow">
<column name="wordCount" type="bigint">
<constraints nullable="false" />
</column>
</modifyColumn>
</ext:modifyColumn>
</changeSet>

<changeSet author="sflaniga@redhat.com" id="4">
Expand Down
@@ -1,5 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<changeSet author="hding@redhat.com" id="1">
<comment>Add flag for project and project version to support a customized list of locales</comment>
<addColumn tableName="HProject">
Expand Down
@@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<changeSet author="camunoz@redhat.com" id="1">
<comment>Add a flag indicating when a member of a Language team (locale) is a team coordinator.</comment>
Expand Down
@@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<changeSet author="aeng@redhat.com" id="1">
<comment>Add table to store glossary entry</comment>
Expand Down
@@ -1,7 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">

<!--
This changelog file (despite the filename) is actually part 2 of the changes for Zanata 1.5.
Expand Down Expand Up @@ -62,17 +65,17 @@
<changeSet author="aeng@redhat.com" id="7">
<comment>Alter HProjectIteration - change status to char(1)</comment>
<sql>UPDATE HProjectIteration SET status=SUBSTRING(status,1,1);</sql>
<modifyColumn tableName="HProjectIteration">
<ext:modifyColumn tableName="HProjectIteration">
<column name="status" type="char(1)"/>
</modifyColumn>
</ext:modifyColumn>
</changeSet>

<changeSet author="sflaniga@redhat.com" id="1">
<comment>Alter HProjectIteration/HProject - change status to char(1)</comment>
<sql>UPDATE HProject SET status=SUBSTRING(status,1,1);</sql>
<modifyColumn tableName="HProject">
<ext:modifyColumn tableName="HProject">
<column name="status" type="char(1)"/>
</modifyColumn>
</ext:modifyColumn>
</changeSet>

<changeSet author="camunoz@redhat.com" id="1-h2" dbms="h2">
Expand All @@ -95,19 +98,19 @@
<sql>UPDATE HTextFlow SET contentHash = MD5(content)</sql>
</changeSet>

<!-- renamed from changeset(camunoz@redhat.com:2) to ensure preconditions are checked again -->
<changeSet author="sflaniga@redhat.com" id="2" dbms="mysql">
<!-- renamed from changeset(camunoz@redhat.com:2 and sflanigan@redhat.com:2) to ensure preconditions are checked again -->
<changeSet author="camunoz@redhat.com" id="3" dbms="mysql">
<preConditions onFail="MARK_RAN">
<sqlCheck expectedResult="1">
SELECT * FROM INFORMATION_SCHEMA.COLUMNS
SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_SCHEMA=SCHEMA() AND TABLE_NAME='HTextFlow'
AND COLUMN_NAME='contentHash' AND DATA_TYPE='varchar';
</sqlCheck>
</preConditions>
<comment>Change Content Hash column on HTextFlow to char(32)</comment>
<modifyColumn tableName="HTextFlow">
<ext:modifyColumn tableName="HTextFlow">
<column name="contentHash" type="char(32)"/>
</modifyColumn>
</ext:modifyColumn>
</changeSet>

<!--
Expand Down
3 changes: 2 additions & 1 deletion server/zanata-war/src/main/resources/db/db.changelog.xml
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.9 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.9.xsd">
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-2.0.xsd">

<include relativeToChangelogFile="true" file="changelogs/db.changelog-1.0.xml"/>
<include relativeToChangelogFile="true" file="changelogs/db.changelog-1.2.xml"/>
Expand Down
Expand Up @@ -31,7 +31,8 @@ CREATE TRIGGER `HTextFlow_Update`
END
GO

DROP TRIGGER IF EXISTS `HTextFlowTarget_Update`;
DROP TRIGGER IF EXISTS `HTextFlowTarget_Update`
GO

CREATE TRIGGER `HTextFlowTarget_Update`
BEFORE UPDATE on `HTextFlowTarget`
Expand Down
12 changes: 6 additions & 6 deletions server/zanata-war/src/main/webapp-jboss/WEB-INF/web.xml
Expand Up @@ -66,36 +66,36 @@
-->

<context-param>
<param-name>LIQUIBASE_CHANGELOG</param-name>
<param-name>liquibase.changelog</param-name>
<param-value>db/db.changelog.xml</param-value>
</context-param>

<context-param>
<param-name>LIQUIBASE_DATA_SOURCE</param-name>
<param-name>liquibase.datasource</param-name>
<param-value>java:/${ds.jndi.name}</param-value>
</context-param>
<!--
<context-param>
<param-name>LIQUIBASE_HOST_EXCLUDES</param-name>
<param-name>liquibase.host.excludes</param-name>
<param-value>production1.example.com, production2.example.com</param-value>
</context-param>
-->

<context-param>
<param-name>LIQUIBASE_FAIL_ON_ERROR</param-name>
<param-name>liquibase.onerror.fail</param-name>
<param-value>true</param-value>
</context-param>

<!--
<context-param>
<param-name>LIQUIBASE_CONTEXTS</param-name>
<param-name>liquibase.contexts</param-name>
<param-value>production</param-value>
</context-param>
-->
<!--
-->
<listener>
<listener-class>liquibase.servlet.LiquibaseServletListener</listener-class>
<listener-class>liquibase.integration.servlet.LiquibaseServletListener</listener-class>
</listener>


Expand Down
10 changes: 8 additions & 2 deletions zanata-parent/pom.xml
Expand Up @@ -839,12 +839,18 @@
<scope>test</scope>
</dependency>

<!-- Liquibase Dependencies -->
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>1.9.5</version>
<version>2.0.3</version>
</dependency>

<dependency>
<groupId>org.liquibase.ext</groupId>
<artifactId>modify-column</artifactId>
<version>2.0.0</version>
</dependency>

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
Expand Down

0 comments on commit 27cdcab

Please sign in to comment.