liquibase demo

pom 依赖
                <dependency>
			<groupId>org.liquibase</groupId>
			<artifactId>liquibase-core</artifactId>
			<version>3.0.8</version>
		</dependency>

build
<build>
		<finalName>v-crm</finalName>

		<plugins>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-compiler-plugin</artifactId>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration>
					<junitArtifactName>junit:junit-dep</junitArtifactName>
				</configuration>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-resources-plugin</artifactId>
			</plugin>

			<plugin>
				<groupId>org.apache.felix</groupId>
				<artifactId>maven-bundle-plugin</artifactId>
				<version>2.3.7</version>
			</plugin>

			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>buildnumber-maven-plugin</artifactId>
				<version>1.2</version>
				<configuration>
					<format>{0,date,yyyy-MM-dd HH:mm:ss}</format>
					<items>
						<item>timestamp</item>
					</items>
				</configuration>
				<executions>
					<execution>
						<phase>validate</phase>
						<goals>
							<goal>create</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<artifactId>maven-war-plugin</artifactId>
				<configuration>
					<useCache>false</useCache>
					<archive>
						<manifest>
							<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
							<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
						</manifest>
						<manifestEntries>
							<Implementation-Environment>${env}</Implementation-Environment>
							<Implementation-Build>${buildNumber}</Implementation-Build>
						</manifestEntries>
					</archive>
					<dependentWarExcludes>WEB-INF/web.xml,WEB-INF/lib/*,WEB-INF/classes/*.xml</dependentWarExcludes>
					<overlays>
						<overlay><!-- 空groupId/artifactId代表当前构建 -->
						</overlay>
						<overlay>
							<groupId>com.lashou.v</groupId>
							<artifactId>v-overlay</artifactId>
							<includes>
								<include>css/</include>
								<include>img/</include>
								<include>WEB-INF/view/</include>
							</includes>
						</overlay>
					</overlays>
				</configuration>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>war</goal>
						</goals>
						<configuration>
							<classifier>${env}</classifier>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<!-- liquibase -->
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>properties-maven-plugin</artifactId>
				<version>1.0-alpha-2</version>
				<configuration>
					<files>
						<file>${basedir}/conf/default/db.properties</file>
					</files>
				</configuration>
				<executions>
					<execution>
						<id>set-properties</id>
						<phase>initialize</phase>
						<goals>
							<goal>read-project-properties</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.liquibase</groupId>
				<artifactId>liquibase-maven-plugin</artifactId>
				<version>3.0.8</version>
				<configuration>
					<changeLogFile>${basedir}/src/main/resources/db/liquibase/changelog.xml</changeLogFile>
					<defaultSchemaName>public</defaultSchemaName>
					<logging>debug</logging>
					<outputFileEncoding>utf-8</outputFileEncoding>
					<driver>${db.crm_cms.driverClassName}</driver>
					<url>jdbc:postgresql://${db.crm_cms.ip}:${db.crm_cms.port}/crm_cms</url>
					<username>${db.liquibase.username}</username>
					<password>${db.liquibase.password}</password>
				</configuration>
			</plugin>
		</plugins>
	</build>


db.properties
#liquibase
db.liquibase.ip=localhost
db.liquibase.port=3306
db.liquibase.username=postgres
db.liquibase.password=postgres

changelog.xml
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
	xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog dbchangelog-3.0.xsd
        http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">


	<preConditions>
		<dbms type="postgresql" />
	</preConditions>

	<changeSet id="init_1" author="reed">
		<comment>grant permissions for liquibase system's tables</comment>
		<sql>
			GRANT SELECT, UPDATE, INSERT ON
			TABLE databasechangelog TO
			group_cms;
			GRANT SELECT, UPDATE, INSERT ON
			TABLE databasechangelog TO
			group_crm;
			GRANT SELECT, UPDATE, INSERT ON
			TABLE databasechangeloglock
			TO group_cms;
			GRANT SELECT, UPDATE, INSERT ON
			TABLE
			databasechangeloglock TO
			group_crm;
		</sql>
	</changeSet>
	<changeSet id="init_0" author="reed">
		<tagDatabase tag="init" />
	</changeSet>
	<!-- include by different versions -->
<!-- 	<include file="classpath:db/liquibase/v/v2.22.xml"/> -->
	<!-- <include file="v/v2.22.xml" relativeToChangelogFile="true"/> -->
	<!-- TMD!!!!!!!!!!!!!there is bug for dbchangelog-3.0.xsd-->
	<!-- So using local xsd:dbchangelog-3.0.xsd then can set resourceFilter for XMLChangeLogSAXHandler-->
	<includeAll path="db/liquibase/v"/>
	<!-- <includeAll path="v" relativeToChangelogFile="true"/> -->


</databaseChangeLog>

dbchangelog-3.0.xsd
<?xml version="1.0" encoding="UTF-8"?>

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            targetNamespace="http://www.liquibase.org/xml/ns/dbchangelog" xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
            elementFormDefault="qualified">

    <xsd:simpleType name="propertyExpression" id="propertyExpression">
        <xsd:restriction base="xsd:string">
            <xsd:pattern value="$\{[\w\.]+\}"/>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:simpleType name="booleanExp" id="booleanExp">
        <xsd:annotation>
            <xsd:appinfo>
                <xsd:documentation>Extension to standard XSD boolean type to allow ${} parameters</xsd:documentation>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:union>
            <xsd:simpleType>
                <xsd:restriction base="xsd:boolean"/>
            </xsd:simpleType>
            <xsd:simpleType>
                <xsd:restriction base="propertyExpression"/>
            </xsd:simpleType>
        </xsd:union>
    </xsd:simpleType>

    <xsd:simpleType name="integerExp" id="integerExp">
        <xsd:annotation>
            <xsd:appinfo>
                <xsd:documentation>Extension to standard XSD integer type to allow ${} parameters</xsd:documentation>
            </xsd:appinfo>
        </xsd:annotation>
        <xsd:union>
            <xsd:simpleType>
                <xsd:restriction base="xsd:integer"/>
            </xsd:simpleType>
            <xsd:simpleType>
                <xsd:restriction base="propertyExpression"/>
            </xsd:simpleType>
        </xsd:union>
    </xsd:simpleType>

    <xsd:simpleType name="onChangeSetPreconditionErrorOrFail">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="HALT" />
            <xsd:enumeration value="WARN" />
            <xsd:enumeration value="CONTINUE" />
            <xsd:enumeration value="MARK_RAN" />
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:simpleType name="onChangeLogPreconditionErrorOrFail">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="HALT" />
            <xsd:enumeration value="WARN" />
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:simpleType name="onChangeLogPreconditionOnSqlOutput">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="TEST" />
            <xsd:enumeration value="FAIL" />
            <xsd:enumeration value="IGNORE" />
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:simpleType name="onChangeSetValidationFail">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="HALT" />
            <xsd:enumeration value="MARK_RAN" />
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:simpleType name="objectQuotingStrategy">
        <xsd:restriction base="xsd:string">
            <xsd:enumeration value="LEGACY" />
            <xsd:enumeration value="QUOTE_ALL_OBJECTS" />
            <xsd:enumeration value="QUOTE_ONLY_RESERVED_WORDS" />
        </xsd:restriction>
    </xsd:simpleType>

    <!-- This is the main (root) part of the xsd -->
    <xsd:element name="databaseChangeLog">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="property" minOccurs="0" maxOccurs="unbounded">
                    <xsd:complexType>
                        <xsd:attribute name="file" type="xsd:string" />
                        <xsd:attribute name="name" type="xsd:string" />
                        <xsd:attribute name="value" type="xsd:string" />
                        <xsd:attribute name="dbms" type="xsd:string" />
                        <xsd:attribute name="context" type="xsd:string" />
                    </xsd:complexType>
                </xsd:element>

                <xsd:element name="preConditions" minOccurs="0"
                             maxOccurs="1">
                    <xsd:complexType>
                        <xsd:choice>
                            <xsd:group ref="PreConditionChildren" maxOccurs="unbounded" />
                        </xsd:choice>
                        <xsd:attribute name="onFailMessage" type="xsd:string" />
                        <xsd:attribute name="onErrorMessage" type="xsd:string" />
                        <xsd:attribute name="onFail"
                                       type="onChangeLogPreconditionErrorOrFail" />
                        <xsd:attribute name="onError"
                                       type="onChangeLogPreconditionErrorOrFail" />
                        <xsd:attribute name="onSqlOutput"
                                       type="onChangeLogPreconditionOnSqlOutput" />
                    </xsd:complexType>
                </xsd:element>

                <xsd:choice minOccurs="0" maxOccurs="unbounded">
                    <xsd:element name="changeSet" minOccurs="0" maxOccurs="unbounded">
                        <xsd:complexType>
                            <xsd:sequence>
                                <xsd:element name="validCheckSum" minOccurs="0"
                                             maxOccurs="unbounded">
                                    <xsd:complexType mixed="true">
                                        <xsd:sequence>
                                            <xsd:element ref="comment" minOccurs="0"
                                                         maxOccurs="1" />
                                        </xsd:sequence>
                                    </xsd:complexType>
                                </xsd:element>
                                <xsd:element name="preConditions" minOccurs="0"
                                             maxOccurs="1">
                                    <xsd:annotation>
                                        <xsd:appinfo>
                                            <xsd:documentation>onChangeLogPreconditionOnSqlOutput determines what should happen when evaluating this precondition in updateSQL mode.  TEST: Run precondition, FAIL: Fail precondition, IGNORE: Skip precondition check [DEFAULT]</xsd:documentation>
                                        </xsd:appinfo>
                                    </xsd:annotation>
                                    <xsd:complexType>
                                        <xsd:choice>
                                            <xsd:group ref="PreConditionChildren" maxOccurs="unbounded" />
                                        </xsd:choice>
                                        <xsd:attribute name="onFailMessage" type="xsd:string" />
                                        <xsd:attribute name="onErrorMessage" type="xsd:string" />
                                        <xsd:attribute name="onFail"
                                                       type="onChangeSetPreconditionErrorOrFail" />
                                        <xsd:attribute name="onError"
                                                       type="onChangeSetPreconditionErrorOrFail" />
                                        <xsd:attribute name="onSqlOutput"
                                                       type="onChangeLogPreconditionOnSqlOutput" />
                                    </xsd:complexType>
                                </xsd:element>
                                <xsd:choice>
                                    <xsd:element ref="tagDatabase" maxOccurs="1" />
                                    <xsd:group ref="changeSetChildren" minOccurs="0"
                                               maxOccurs="unbounded" />
                                </xsd:choice>

                                <xsd:element name="modifySql" minOccurs="0"
                                             maxOccurs="unbounded">
                                    <xsd:complexType>
                                        <xsd:choice>
                                            <xsd:group ref="modifySqlChildren" minOccurs="1"
                                                       maxOccurs="unbounded" />
                                        </xsd:choice>
                                        <xsd:attribute name="dbms" type="xsd:string" />
                                        <xsd:attribute name="context" type="xsd:string" />
                                        <xsd:attribute name="applyToRollback" type="booleanExp" />
                                    </xsd:complexType>
                                </xsd:element>

                            </xsd:sequence>
                            <xsd:attributeGroup ref="changeSetAttributes" />
                            <xsd:anyAttribute namespace="##other" />
                        </xsd:complexType>
                    </xsd:element>

                    <!-- include -->
                    <xsd:element name="include" minOccurs="0" maxOccurs="unbounded">
                        <xsd:complexType>
                            <xsd:attribute name="file" type="xsd:string" use="required" />
                            <xsd:attribute name="relativeToChangelogFile" type="booleanExp" />
                            <xsd:anyAttribute namespace="##other" />
                        </xsd:complexType>
                    </xsd:element>
                    <xsd:element name="includeAll" minOccurs="0" maxOccurs="unbounded">
                        <xsd:complexType>
                            <xsd:attribute name="path" type="xsd:string" use="required" />
                            <xsd:attribute name="relativeToChangelogFile" type="booleanExp" />
                            <xsd:attribute name="resourceFilter" type="xsd:string" />
                            <xsd:anyAttribute namespace="##other" />
                        </xsd:complexType>
                    </xsd:element>
                </xsd:choice>
            </xsd:sequence>
            <xsd:attributeGroup ref="changeLogAttributes" />
            <xsd:anyAttribute namespace="##other" />
        </xsd:complexType>
    </xsd:element>

    <xsd:group name="modifySqlChildren">
        <xsd:choice>
            <xsd:element name="replace" minOccurs="0" maxOccurs="unbounded">
                <xsd:complexType>
                    <xsd:attribute name="replace" type="xsd:string" use="required" />
                    <xsd:attribute name="with" type="xsd:string" use="required" />
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="regExpReplace" minOccurs="0"
                         maxOccurs="unbounded">
                <xsd:complexType>
                    <xsd:attribute name="replace" type="xsd:string" use="required" />
                    <xsd:attribute name="with" type="xsd:string" use="required" />
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="prepend" minOccurs="0" maxOccurs="unbounded">
                <xsd:complexType>
                    <xsd:attribute name="value" type="xsd:string" use="required" />
                </xsd:complexType>
            </xsd:element>
            <xsd:element name="append" minOccurs="0" maxOccurs="unbounded">
                <xsd:complexType>
                    <xsd:attribute name="value" type="xsd:string" use="required" />
                </xsd:complexType>
            </xsd:element>
        </xsd:choice>
    </xsd:group>

    <!-- Attributes for DatabaseInfo -->
    <xsd:attributeGroup name="DatabaseInfoAttributes">
        <xsd:attribute name="type" type="xsd:string" />
        <xsd:attribute name="version" type="xsd:string" />
        <xsd:attribute name="username" type="xsd:string" />
        <xsd:attribute name="password" type="xsd:string" />
        <xsd:attribute name="port" type="integerExp" />
        <xsd:attribute name="host" type="xsd:string" />
        <xsd:attribute name="schemaName" type="xsd:string" />
        <xsd:attribute name="driverName" type="xsd:string" />
    </xsd:attributeGroup>

    <!-- Attributes for changeSet -->
    <xsd:attributeGroup name="changeLogAttributes">
        <xsd:attribute name="logicalFilePath" type="xsd:string" />
        <xsd:attribute name="objectQuotingStrategy" type="objectQuotingStrategy" default="LEGACY" />
    </xsd:attributeGroup>

    <!-- Attributes for changeSet -->
    <xsd:attributeGroup name="changeSetAttributes">
        <xsd:attribute name="id" type="xsd:string" use="required" />
        <xsd:attribute name="author" type="xsd:string" use="required" />
        <xsd:attribute name="context" type="xsd:string" />
        <xsd:attribute name="dbms" type="xsd:string" />
        <xsd:attribute name="runOnChange" type="booleanExp" />
        <xsd:attribute name="runAlways" type="booleanExp" />
        <xsd:attribute name="failOnError" type="booleanExp" />
        <xsd:attribute name="onValidationFail" type="onChangeSetValidationFail" />
        <xsd:attribute name="runInTransaction" type="booleanExp" default="true" />
        <xsd:attribute name="logicalFilePath" type="xsd:string" />
        <xsd:attribute name="objectQuotingStrategy" type="objectQuotingStrategy" />
    </xsd:attributeGroup>

    <!-- Attributes for constraints -->
    <xsd:attributeGroup name="constraintsAttributes">
        <xsd:attribute name="nullable" type="booleanExp" />
        <xsd:attribute name="primaryKey" type="booleanExp" />
        <xsd:attribute name="primaryKeyName" type="xsd:string" />
        <xsd:attribute name="primaryKeyTablespace" type="xsd:string" />
        <xsd:attribute name="unique" type="booleanExp" />
        <xsd:attribute name="uniqueConstraintName" type="xsd:string" />
        <xsd:attribute name="references" type="xsd:string" />
        <xsd:attribute name="referencedTableName" type="xsd:string"/>
        <xsd:attribute name="referencedColumnNames" type="xsd:string"/>
        <xsd:attribute name="foreignKeyName" type="xsd:string" />
        <xsd:attribute name="deleteCascade" type="booleanExp" />
        <xsd:attribute name="deferrable" type="booleanExp" />
        <xsd:attribute name="initiallyDeferred" type="booleanExp" />
        <xsd:attribute name="checkConstraint" type="xsd:string" />
    </xsd:attributeGroup>

    <xsd:attributeGroup name="column">
        <xsd:attribute name="name" type="xsd:string" use="required" />
        <xsd:attribute name="type" type="xsd:string" />
        <xsd:attribute name="value" type="xsd:string" />
        <xsd:attribute name="valueNumeric" type="xsd:string" />
        <xsd:attribute name="valueBoolean" type="xsd:string" />
        <xsd:attribute name="valueDate" type="xsd:string" />
        <xsd:attribute name="valueComputed" type="xsd:string" />
        <xsd:attribute name="valueSequenceCurrent" type="xsd:string" />
        <xsd:attribute name="valueSequenceNext" type="xsd:string" />
        <xsd:attribute name="valueBlobFile" type="xsd:string"/>
        <xsd:attribute name="valueClobFile" type="xsd:string"/>
        <xsd:attribute name="defaultValue" type="xsd:string" />
        <xsd:attribute name="defaultValueNumeric" type="xsd:string" />
        <xsd:attribute name="defaultValueDate" type="xsd:string" />
        <xsd:attribute name="defaultValueBoolean" type="booleanExp" />
        <xsd:attribute name="defaultValueComputed" type="xsd:string" />
        <xsd:attribute name="defaultValueSequenceCurrent" type="xsd:string" />
        <xsd:attribute name="defaultValueSequenceNext" type="xsd:string" />
        <xsd:attribute name="autoIncrement" type="booleanExp" />
        <xsd:attribute name="startWith" type="xsd:long" />
        <xsd:attribute name="incrementBy" type="xsd:long" />
        <xsd:attribute name="remarks" type="xsd:string" />
    </xsd:attributeGroup>

    <xsd:attributeGroup name="param">
        <xsd:attribute name="name" type="xsd:string" />
        <xsd:attribute name="value" type="xsd:string" />
        <xsd:attribute name="valueNumeric" type="xsd:string" />
        <xsd:attribute name="valueBoolean" type="xsd:string" />
        <xsd:attribute name="valueDate" type="xsd:string" />
        <xsd:attribute name="valueComputed" type="xsd:string" />
        <xsd:attribute name="valueSequenceNext" type="xsd:string" />
        <xsd:attribute name="valueSequenceCurrent" type="xsd:string" />
    </xsd:attributeGroup>

    <xsd:attributeGroup name="tableNameAttribute">
        <xsd:attribute name="catalogName" type="xsd:string" />
        <xsd:attribute name="schemaName" type="xsd:string" />
        <xsd:attribute name="tableName" type="xsd:string" use="required" />
    </xsd:attributeGroup>

    <xsd:attributeGroup name="dropTableAttributes">
        <xsd:attributeGroup ref="tableNameAttribute" />
        <xsd:attribute name="cascadeConstraints" type="booleanExp" />
    </xsd:attributeGroup>

    <xsd:attributeGroup name="renameTableAttributes">
        <xsd:attribute name="catalogName" type="xsd:string" />
        <xsd:attribute name="schemaName" type="xsd:string" />
        <xsd:attribute name="oldTableName" type="xsd:string"
                       use="required" />
        <xsd:attribute name="newTableName" type="xsd:string"
                       use="required" />
    </xsd:attributeGroup>

    <xsd:attributeGroup name="renameViewAttributes">
        <xsd:attribute name="catalogName" type="xsd:string" />
        <xsd:attribute name="schemaName" type="xsd:string" />
        <xsd:attribute name="oldViewName" type="xsd:string" use="required" />
        <xsd:attribute name="newViewName" type="xsd:string" use="required" />
    </xsd:attributeGroup>

    <xsd:attributeGroup name="renameColumnAttributes">
        <xsd:attributeGroup ref="tableNameAttribute" />
        <xsd:attribute name="oldColumnName" type="xsd:string"
                       use="required" />
        <xsd:attribute name="newColumnName" type="xsd:string"
                       use="required" />
        <xsd:attribute name="columnDataType" type="xsd:string" />
    </xsd:attributeGroup>

    <xsd:attributeGroup name="dropColumnAttributes">
        <xsd:attributeGroup ref="tableNameAttribute" />
        <xsd:attribute name="columnName" type="xsd:string" use="required" />
    </xsd:attributeGroup>

    <xsd:attributeGroup name="sequenceAttributes">
        <xsd:attribute name="catalogName" type="xsd:string" />
        <xsd:attribute name="schemaName" type="xsd:string" />
        <xsd:attribute name="sequenceName" type="xsd:string"
                       use="required" />
        <xsd:attribute name="startValue" type="xsd:string" />
        <xsd:attribute name="incrementBy" type="xsd:string" />
        <xsd:attribute name="maxValue" type="xsd:string" />
        <xsd:attribute name="minValue" type="xsd:string" />
        <xsd:attribute name="ordered" type="booleanExp" />
    </xsd:attributeGroup>

    <xsd:attributeGroup name="indexName">
        <xsd:attribute name="indexName" type="xsd:string" use="required" />
    </xsd:attributeGroup>

    <xsd:attributeGroup name="createIndex">
        <xsd:attributeGroup ref="tableNameAttribute" />
        <xsd:attributeGroup ref="indexName" />
        <xsd:attribute name="associatedWith" type="xsd:string" use="optional" />
        <xsd:attribute name="unique" type="booleanExp" />
        <xsd:attribute name="tablespace" type="xsd:string" />
    </xsd:attributeGroup>


    <xsd:element name="addPrimaryKey">
        <xsd:complexType>
            <xsd:attributeGroup ref="tableNameAttribute" />
            <xsd:attribute name="columnNames" type="xsd:string"
                           use="required" />
            <xsd:attribute name="constraintName" type="xsd:string" />
            <xsd:attribute name="tablespace" type="xsd:string" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="dropPrimaryKey">
        <xsd:complexType>
            <xsd:attributeGroup ref="tableNameAttribute" />
            <xsd:attribute name="constraintName" type="xsd:string" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="addUniqueConstraint">
        <xsd:complexType>
            <xsd:attributeGroup ref="tableNameAttribute" />
            <xsd:attribute name="columnNames" type="xsd:string"
                           use="required" />
            <xsd:attribute name="constraintName" type="xsd:string" />
            <xsd:attribute name="tablespace" type="xsd:string" />
            <xsd:attribute name="disabled" type="booleanExp" />
            <xsd:attribute name="deferrable" type="booleanExp" />
            <xsd:attribute name="initiallyDeferred" type="booleanExp" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="dropUniqueConstraint">
        <xsd:complexType>
            <xsd:attributeGroup ref="tableNameAttribute" />
            <xsd:attribute name="constraintName" type="xsd:string" />
            <xsd:attribute name="uniqueColumns" type="xsd:string" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="modifyDataType">
        <xsd:complexType>
            <xsd:attributeGroup ref="tableNameAttribute" />
            <xsd:attribute name="columnName" type="xsd:string" use="required" />
            <xsd:attribute name="newDataType" type="xsd:string" use="required" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="addLookupTable">
        <xsd:complexType>
            <xsd:attribute name="existingTableCatalogName" type="xsd:string" />
            <xsd:attribute name="existingTableSchemaName" type="xsd:string" />
            <xsd:attribute name="existingTableName" type="xsd:string"
                           use="required" />
            <xsd:attribute name="existingColumnName" type="xsd:string"
                           use="required" />
            <xsd:attribute name="newTableCatalogName" type="xsd:string" />
            <xsd:attribute name="newTableSchemaName" type="xsd:string" />
            <xsd:attribute name="newTableName" type="xsd:string"
                           use="required" />
            <xsd:attribute name="newColumnName" type="xsd:string"
                           use="required" />
            <xsd:attribute name="newColumnDataType" type="xsd:string" />
            <xsd:attribute name="constraintName" type="xsd:string" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="addAutoIncrement">
        <xsd:complexType>
            <xsd:attributeGroup ref="tableNameAttribute" />
            <xsd:attribute name="columnName" type="xsd:string" use="required" />
            <xsd:attribute name="columnDataType" type="xsd:string" />
            <xsd:attribute name="startWith" type="xsd:long" />
            <xsd:attribute name="incrementBy" type="xsd:long" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="addDefaultValue">
        <xsd:complexType>
            <xsd:attributeGroup ref="tableNameAttribute" />
            <xsd:attribute name="columnName" type="xsd:string" use="required" />
            <xsd:attribute name="columnDataType" type="xsd:string" />
            <xsd:attribute name="defaultValue" type="xsd:string" />
            <xsd:attribute name="defaultValueNumeric" type="xsd:string" />
            <xsd:attribute name="defaultValueDate" type="xsd:string" />
            <xsd:attribute name="defaultValueBoolean" type="xsd:string" />
            <xsd:attribute name="defaultValueComputed" type="xsd:string" />
            <xsd:attribute name="defaultValueSequenceNext" type="xsd:string" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="dropDefaultValue">
        <xsd:complexType>
            <xsd:attributeGroup ref="tableNameAttribute" />
            <xsd:attribute name="columnName" type="xsd:string" use="required" />
            <xsd:attribute name="columnDataType" type="xsd:string" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="loadData">
        <xsd:complexType mixed="true">
            <xsd:sequence>
                <xsd:element name="column" minOccurs="0" maxOccurs="unbounded">
                    <xsd:complexType>
                        <xsd:attribute name="index" type="integerExp" />
                        <xsd:attribute name="header" type="xsd:string" />
                        <xsd:attribute name="name" type="xsd:string" />
                        <xsd:attribute name="type" type="xsd:string" />
                        <xsd:attribute name="defaultValue" type="xsd:string" />
                        <xsd:attribute name="defaultValueNumeric" type="xsd:string" />
                        <xsd:attribute name="defaultValueDate" type="xsd:string" />
                        <xsd:attribute name="defaultValueBoolean" type="booleanExp" />
                        <xsd:attribute name="defaultValueComputed" type="xsd:string" />
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
            <xsd:attributeGroup ref="tableNameAttribute" />
            <xsd:attribute name="file" type="xsd:string" />
            <xsd:attribute name="encoding" type="xsd:string" default="UTF-8"/>
            <xsd:attribute name="separator" type="xsd:string" default=","/>
            <xsd:attribute name="quotchar" type="xsd:string" default="&quot;"/>
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="loadUpdateData">
        <xsd:complexType mixed="true">
            <xsd:sequence>
                <xsd:element name="column" minOccurs="0" maxOccurs="unbounded">
                    <xsd:complexType>
                        <xsd:attribute name="index" type="integerExp" />
                        <xsd:attribute name="header" type="xsd:string" />
                        <xsd:attribute name="name" type="xsd:string" />
                        <xsd:attribute name="type" type="xsd:string" />
                        <xsd:attribute name="defaultValue" type="xsd:string" />
                        <xsd:attribute name="defaultValueNumeric" type="xsd:string" />
                        <xsd:attribute name="defaultValueDate" type="xsd:string" />
                        <xsd:attribute name="defaultValueBoolean" type="booleanExp" />
                        <xsd:attribute name="defaultValueComputed" type="xsd:string" />
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
            <xsd:attributeGroup ref="tableNameAttribute" />
            <xsd:attribute name="file" type="xsd:string" />
            <xsd:attribute name="encoding" type="xsd:string" default="UTF-8"/>
            <xsd:attribute name="primaryKey" type="xsd:string" use="required" />
            <xsd:attribute name="separator" type="xsd:string" default=","/>
            <xsd:attribute name="quotchar" type="xsd:string" default="&quot;"/>
        </xsd:complexType>
    </xsd:element>

    <xsd:simpleType name="fkCascadeActionOptions">
        <xsd:restriction base="xsd:token">
            <xsd:enumeration value="CASCADE"></xsd:enumeration>
            <xsd:enumeration value="SET NULL"></xsd:enumeration>
            <xsd:enumeration value="SET DEFAULT"></xsd:enumeration>
            <xsd:enumeration value="RESTRICT"></xsd:enumeration>
            <xsd:enumeration value="NO ACTION"></xsd:enumeration>
        </xsd:restriction>
    </xsd:simpleType>

    <xsd:attributeGroup name="addForeignKeyConstraintAttrib">
        <xsd:attribute name="baseTableCatalogName" type="xsd:string" />
        <xsd:attribute name="baseTableSchemaName" type="xsd:string" />
        <xsd:attribute name="baseTableName" type="xsd:string"
                       use="required" />
        <xsd:attribute name="baseColumnNames" type="xsd:string"
                       use="required" />
        <xsd:attribute name="constraintName" type="xsd:string"
                       use="required" />
        <xsd:attribute name="referencedTableCatalogName" type="xsd:string" />
        <xsd:attribute name="referencedTableSchemaName" type="xsd:string" />
        <xsd:attribute name="referencedTableName" type="xsd:string"
                       use="required" />
        <xsd:attribute name="referencedColumnNames" type="xsd:string"
                       use="required" />
        <xsd:attribute name="deferrable" type="booleanExp" />
        <xsd:attribute name="initiallyDeferred" type="booleanExp" />
        <xsd:attribute name="deleteCascade" type="booleanExp" />
        <xsd:attribute name="onDelete" type="fkCascadeActionOptions" />
        <xsd:attribute name="onUpdate" type="fkCascadeActionOptions" />
        <xsd:attribute name="referencesUniqueColumn" type="booleanExp" />
    </xsd:attributeGroup>

    <xsd:attributeGroup name="addNotNullConstraintAttrib">
        <xsd:attributeGroup ref="tableNameAttribute" />
        <xsd:attribute name="columnName" type="xsd:string" use="required" />
        <xsd:attribute name="defaultNullValue" type="xsd:string" />
        <xsd:attribute name="columnDataType" type="xsd:string" />
    </xsd:attributeGroup>


    <xsd:element name="addNotNullConstraint">
        <xsd:complexType>
            <xsd:attributeGroup ref="addNotNullConstraintAttrib" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="addForeignKeyConstraint">
        <xsd:complexType>
            <xsd:attributeGroup ref="addForeignKeyConstraintAttrib" />
        </xsd:complexType>
    </xsd:element>

    <xsd:attributeGroup name="dbmsAttrib">
        <xsd:attribute name="type" type="xsd:string" use="required" />
    </xsd:attributeGroup>

    <xsd:element name="dbms">
        <xsd:complexType>
            <xsd:attributeGroup ref="dbmsAttrib" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="changeSetExecuted">
        <xsd:complexType>
            <xsd:attribute name="id" type="xsd:string" use="required" />
            <xsd:attribute name="author" type="xsd:string" use="required" />
            <xsd:attribute name="changeLogFile" type="xsd:string"
                           use="required" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="tableExists">
        <xsd:complexType>
            <xsd:attribute name="catalogName" type="xsd:string" />
            <xsd:attribute name="schemaName" type="xsd:string" />
            <xsd:attribute name="tableName" type="xsd:string" use="required" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="columnExists">
        <xsd:complexType>
            <xsd:attribute name="catalogName" type="xsd:string" />
            <xsd:attribute name="schemaName" type="xsd:string" />
            <xsd:attribute name="tableName" type="xsd:string" use="required" />
            <xsd:attribute name="columnName" type="xsd:string" use="required" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="sequenceExists">
        <xsd:complexType>
            <xsd:attribute name="catalogName" type="xsd:string" />
            <xsd:attribute name="schemaName" type="xsd:string" />
            <xsd:attribute name="sequenceName" type="xsd:string"
                           use="required" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="foreignKeyConstraintExists">
        <xsd:complexType>
            <xsd:attribute name="catalogName" type="xsd:string" />
            <xsd:attribute name="schemaName" type="xsd:string" />
            <xsd:attribute name="foreignKeyTableName" type="xsd:string" />
            <xsd:attribute name="foreignKeyName" type="xsd:string"
                           use="required" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="indexExists">
        <xsd:complexType>
            <xsd:attribute name="catalogName" type="xsd:string" />
            <xsd:attribute name="schemaName" type="xsd:string" />
            <xsd:attribute name="indexName" type="xsd:string"/>
            <xsd:attribute name="tableName" type="xsd:string" />
            <xsd:attribute name="columnNames" type="xsd:string" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="changeLogPropertyDefined">
        <xsd:complexType>
            <xsd:attribute name="property" type="xsd:string" use="required" />
            <xsd:attribute name="value" type="xsd:string" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="primaryKeyExists">
        <xsd:complexType>
            <xsd:attribute name="catalogName" type="xsd:string" />
            <xsd:attribute name="schemaName" type="xsd:string" />
            <xsd:attribute name="primaryKeyName" type="xsd:string" />
            <xsd:attribute name="tableName" type="xsd:string" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="viewExists">
        <xsd:complexType>
            <xsd:attribute name="catalogName" type="xsd:string" />
            <xsd:attribute name="schemaName" type="xsd:string" />
            <xsd:attribute name="viewName" type="xsd:string" use="required" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="sqlCheck">
        <xsd:complexType mixed="true">
            <xsd:attribute name="expectedResult" type="xsd:string"
                           use="required" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="customPrecondition">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="param" minOccurs="0" maxOccurs="unbounded">
                    <xsd:complexType>
                        <xsd:attribute name="name" type="xsd:string" use="required" />
                        <xsd:attribute name="value" type="xsd:string" use="required" />
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
            <xsd:attribute name="className" type="xsd:string" use="required" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="and">
        <xsd:complexType>
            <xsd:choice>
                <xsd:group ref="PreConditionChildren" minOccurs="1"
                           maxOccurs="unbounded" />
            </xsd:choice>
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="or">
        <xsd:complexType>
            <xsd:choice>
                <xsd:group ref="PreConditionChildren" minOccurs="1"
                           maxOccurs="unbounded" />
            </xsd:choice>
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="not">
        <xsd:complexType>
            <xsd:choice>
                <xsd:group ref="PreConditionChildren" minOccurs="1"
                           maxOccurs="unbounded" />
            </xsd:choice>
        </xsd:complexType>
    </xsd:element>

    <xsd:attributeGroup name="runningAsAttrib">
        <xsd:attribute name="username" type="xsd:string" use="required" />
    </xsd:attributeGroup>

    <xsd:element name="runningAs">
        <xsd:complexType>
            <xsd:attributeGroup ref="runningAsAttrib" />
        </xsd:complexType>
    </xsd:element>

    <xsd:attributeGroup name="objectQuotingStrategyAttrib">
        <xsd:attribute name="strategy" type="xsd:string" use="required" />
    </xsd:attributeGroup>

    <xsd:element name="expectedQuotingStrategy">
        <xsd:complexType>
            <xsd:attributeGroup ref="objectQuotingStrategyAttrib" />
        </xsd:complexType>
    </xsd:element>

    <xsd:attributeGroup name="dropForeignKeyConstraintAttrib">
        <xsd:attribute name="baseTableCatalogName" type="xsd:string" />
        <xsd:attribute name="baseTableSchemaName" type="xsd:string" />
        <xsd:attribute name="baseTableName" type="xsd:string"
                       use="required" />
        <xsd:attribute name="constraintName" type="xsd:string" />
    </xsd:attributeGroup>

    <xsd:element name="dropForeignKeyConstraint">
        <xsd:complexType>
            <xsd:attributeGroup ref="dropForeignKeyConstraintAttrib" />
        </xsd:complexType>
    </xsd:element>

    <xsd:attributeGroup name="dropAllForeignKeyConstraintsAttrib">
        <xsd:attribute name="baseTableCatalogName" type="xsd:string" />
        <xsd:attribute name="baseTableSchemaName" type="xsd:string" />
        <xsd:attribute name="baseTableName" type="xsd:string"
                       use="required" />
    </xsd:attributeGroup>

    <xsd:element name="dropAllForeignKeyConstraints">
        <xsd:complexType>
            <xsd:attributeGroup ref="dropAllForeignKeyConstraintsAttrib" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="dropNotNullConstraint">
        <xsd:complexType>
            <xsd:attribute name="catalogName" type="xsd:string" />
            <xsd:attribute name="schemaName" type="xsd:string" />
            <xsd:attribute name="tableName" type="xsd:string" use="required" />
            <xsd:attribute name="columnName" type="xsd:string" use="required" />
            <xsd:attribute name="columnDataType" type="xsd:string" />
        </xsd:complexType>
    </xsd:element>


    <xsd:element name="constraints">
        <xsd:complexType>
            <xsd:attributeGroup ref="constraintsAttributes" />
        </xsd:complexType>
    </xsd:element>


    <xsd:element name="column">
        <xsd:complexType mixed="true">
            <xsd:sequence>
                <xsd:element ref="constraints" minOccurs="0" />
            </xsd:sequence>
            <xsd:attributeGroup ref="column" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="param">
        <xsd:complexType>
            <xsd:attributeGroup ref="param" />
        </xsd:complexType>
    </xsd:element>

    <!-- Children for createTable -->
    <xsd:element name="createTable">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="column" minOccurs="1" maxOccurs="unbounded" />
            </xsd:sequence>
            <xsd:attributeGroup ref="tableNameAttribute" />
            <xsd:attribute name="tablespace" type="xsd:string" />
            <xsd:attribute name="remarks" type="xsd:string" />
        </xsd:complexType>
    </xsd:element>

    <!-- Children for createView -->
    <xsd:element name="createView">
        <xsd:complexType>
            <xsd:simpleContent>
                <xsd:extension base="xsd:string">
                    <xsd:attribute name="catalogName" type="xsd:string" />
                    <xsd:attribute name="schemaName" type="xsd:string" />
                    <xsd:attribute name="viewName" type="xsd:string" use="required" />
                    <xsd:attribute name="replaceIfExists" type="booleanExp" />
                </xsd:extension>
            </xsd:simpleContent>
        </xsd:complexType>
    </xsd:element>

    <!-- Children for insert -->
    <xsd:element name="insert">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="column" maxOccurs="unbounded" />
            </xsd:sequence>
            <xsd:attributeGroup ref="tableNameAttribute" />
            <xsd:attribute name="dbms" type="xsd:string" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="update">
        <xsd:complexType mixed="true">
            <xsd:sequence>
                <xsd:element ref="column" minOccurs="1" maxOccurs="unbounded" />
                <xsd:element name="where" minOccurs="0" maxOccurs="1" />
                <xsd:element ref="whereParams" minOccurs="0" maxOccurs="1" />
            </xsd:sequence>
            <xsd:attributeGroup ref="tableNameAttribute" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="whereParams">
        <xsd:complexType mixed="true">
            <xsd:sequence>
                <xsd:element ref="param" minOccurs="1" maxOccurs="unbounded" />
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="delete">
        <xsd:complexType mixed="true">
            <xsd:sequence>
                <xsd:element name="where" minOccurs="0" maxOccurs="1" />
                <xsd:element ref="whereParams" minOccurs="0" maxOccurs="1" />
            </xsd:sequence>
            <xsd:attributeGroup ref="tableNameAttribute" />
        </xsd:complexType>
    </xsd:element>

    <!-- Children for addColum -->
    <xsd:element name="addColumn">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="column" minOccurs="1" maxOccurs="unbounded" />
            </xsd:sequence>
            <xsd:attributeGroup ref="tableNameAttribute" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="rollback">
        <xsd:complexType mixed="true">
            <xsd:choice>
                <xsd:group ref="changeSetChildren" minOccurs="0"
                           maxOccurs="unbounded" />
            </xsd:choice>
            <xsd:attribute name="changeSetPath" type="xsd:string" />
            <xsd:attribute name="changeSetAuthor" type="xsd:string" />
            <xsd:attribute name="changeSetId" type="xsd:string" />
        </xsd:complexType>
    </xsd:element>

    <!-- comment  -->
    <xsd:element name="comment" type="xsd:string" />

    <!-- sql -->
    <xsd:element name="sql">
        <xsd:complexType mixed="true">
            <xsd:sequence>
                <xsd:element ref="comment" minOccurs="0" maxOccurs="1" />
            </xsd:sequence>
            <xsd:attribute name="stripComments" type="booleanExp" />
            <xsd:attribute name="splitStatements" type="booleanExp" />
            <xsd:attribute name="endDelimiter" type="xsd:string" />
            <xsd:attribute name="dbms" type="xsd:string" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="createProcedure">
        <xsd:complexType mixed="true">
            <xsd:sequence>
                <xsd:element ref="comment" minOccurs="0" maxOccurs="1" />
            </xsd:sequence>
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="executeCommand">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="arg" minOccurs="0" maxOccurs="unbounded">
                    <xsd:complexType>
                        <xsd:attribute name="value" type="xsd:string" use="required" />
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
            <xsd:attribute name="executable" type="xsd:string" use="required" />
            <xsd:attribute name="os" type="xsd:string" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="sqlFile">
        <xsd:complexType>
            <xsd:attribute name="path" type="xsd:string" use="required" />
            <xsd:attribute name="stripComments" type="booleanExp" />
            <xsd:attribute name="splitStatements" type="booleanExp" />
            <xsd:attribute name="encoding" type="xsd:string" default="UTF-8"/>
            <xsd:attribute name="endDelimiter" type="xsd:string" />
            <xsd:attribute name="relativeToChangelogFile" type="booleanExp" />
            <xsd:attribute name="dbms" type="xsd:string" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="tagDatabase">
        <xsd:complexType>
            <xsd:attribute name="tag" type="xsd:string" use="required" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="stop">
        <xsd:complexType mixed="true" />
    </xsd:element>

    <!-- renameTable -->
    <xsd:element name="renameTable">
        <xsd:complexType>
            <xsd:attributeGroup ref="renameTableAttributes" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="renameView">
        <xsd:complexType>
            <xsd:attributeGroup ref="renameViewAttributes" />
        </xsd:complexType>
    </xsd:element>

    <!-- dropTable -->
    <xsd:element name="dropTable">
        <xsd:complexType>
            <xsd:attributeGroup ref="dropTableAttributes" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="dropView">
        <xsd:complexType>
            <xsd:attribute name="viewName" type="xsd:string" use="required" />
            <xsd:attribute name="catalogName" type="xsd:string" />
            <xsd:attribute name="schemaName" type="xsd:string" />
        </xsd:complexType>
    </xsd:element>

    <!-- renameColumn -->
    <xsd:element name="renameColumn">
        <xsd:complexType>
            <xsd:attributeGroup ref="renameColumnAttributes" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="dropColumn">
        <xsd:complexType>
            <xsd:attributeGroup ref="dropColumnAttributes" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="mergeColumns">
        <xsd:complexType>
            <xsd:attributeGroup ref="tableNameAttribute" />
            <xsd:attribute name="column1Name" type="xsd:string"
                           use="required" />
            <xsd:attribute name="joinString" type="xsd:string" use="required" />
            <xsd:attribute name="column2Name" type="xsd:string"
                           use="required" />
            <xsd:attribute name="finalColumnName" type="xsd:string"
                           use="required" />
            <xsd:attribute name="finalColumnType" type="xsd:string"
                           use="required" />
        </xsd:complexType>
    </xsd:element>

    <xsd:group name="whereClause">
        <xsd:sequence>
            <xsd:element name="whereClause" type="xsd:string"
                         minOccurs="0" maxOccurs="unbounded" />
        </xsd:sequence>
    </xsd:group>

    <xsd:element name="createSequence">
        <xsd:complexType>
            <xsd:attributeGroup ref="sequenceAttributes" />
            <xsd:attribute name="cycle" type="booleanExp">
                <xsd:annotation>
                    <xsd:documentation>
                        true for a cycling sequence, false for a non-cycling sequence.
                        Default is false.
                    </xsd:documentation>
                </xsd:annotation>
            </xsd:attribute>
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="alterSequence">
        <xsd:complexType>
            <xsd:attributeGroup ref="sequenceAttributes" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="dropSequence">
        <xsd:complexType>
            <xsd:attributeGroup ref="sequenceAttributes" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="createIndex">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element ref="column" maxOccurs="unbounded" />
            </xsd:sequence>
            <xsd:attributeGroup ref="createIndex" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="dropIndex">
        <xsd:complexType>
            <xsd:attributeGroup ref="tableNameAttribute" />
            <xsd:attributeGroup ref="indexName" />
            <xsd:attribute name="associatedWith" type="xsd:string" use="optional" />
        </xsd:complexType>
    </xsd:element>

    <xsd:element name="customChange">
        <xsd:complexType>
            <xsd:sequence>
                <xsd:element name="param" minOccurs="0" maxOccurs="unbounded">
                    <xsd:complexType mixed="true">
                        <xsd:attribute name="name" type="xsd:string" use="required" />
                        <xsd:attribute name="value" type="xsd:string" />
                    </xsd:complexType>
                </xsd:element>
            </xsd:sequence>
            <xsd:attribute name="class" type="xsd:string" use="required" />
            <xsd:anyAttribute processContents="lax" />
        </xsd:complexType>
    </xsd:element>


    <!-- Children for changeSet -->
    <xsd:group name="changeSetChildren">
        <xsd:choice>
            <xsd:element ref="comment" maxOccurs="1" />
            <xsd:element ref="createTable" maxOccurs="unbounded" />
            <xsd:element ref="dropTable" maxOccurs="unbounded" />
            <xsd:element ref="createView" maxOccurs="unbounded" />
            <xsd:element ref="renameView" maxOccurs="unbounded" />
            <xsd:element ref="dropView" maxOccurs="unbounded" />
            <xsd:element ref="insert" maxOccurs="unbounded" />
            <xsd:element ref="addColumn" maxOccurs="unbounded" />
            <xsd:element ref="sql" maxOccurs="unbounded" />
            <xsd:element ref="createProcedure" maxOccurs="unbounded" />
            <xsd:element ref="sqlFile" maxOccurs="unbounded" />
            <xsd:element ref="renameTable" maxOccurs="unbounded" />
            <xsd:element ref="renameColumn" maxOccurs="unbounded" />
            <xsd:element ref="dropColumn" maxOccurs="unbounded" />
            <xsd:element ref="mergeColumns" maxOccurs="unbounded" />
            <xsd:element ref="modifyDataType" maxOccurs="unbounded" />
            <xsd:element ref="createSequence" maxOccurs="unbounded" />
            <xsd:element ref="alterSequence" maxOccurs="unbounded" />
            <xsd:element ref="dropSequence" maxOccurs="unbounded" />
            <xsd:element ref="createIndex" maxOccurs="unbounded" />
            <xsd:element ref="dropIndex" maxOccurs="unbounded" />
            <xsd:element ref="addNotNullConstraint" maxOccurs="unbounded" />
            <xsd:element ref="dropNotNullConstraint" maxOccurs="unbounded" />
            <xsd:element ref="addForeignKeyConstraint" maxOccurs="unbounded" />
            <xsd:element ref="dropForeignKeyConstraint" maxOccurs="unbounded" />
            <xsd:element ref="dropAllForeignKeyConstraints"
                         maxOccurs="unbounded" />
            <xsd:element ref="addPrimaryKey" maxOccurs="unbounded" />
            <xsd:element ref="dropPrimaryKey" maxOccurs="unbounded" />
            <xsd:element ref="addLookupTable" maxOccurs="unbounded" />
            <xsd:element ref="addAutoIncrement" maxOccurs="unbounded" />
            <xsd:element ref="addDefaultValue" maxOccurs="unbounded" />
            <xsd:element ref="dropDefaultValue" maxOccurs="unbounded" />
            <xsd:element ref="addUniqueConstraint" maxOccurs="unbounded" />
            <xsd:element ref="dropUniqueConstraint" maxOccurs="unbounded" />
            <xsd:element ref="customChange" maxOccurs="unbounded" />
            <xsd:element ref="update" maxOccurs="unbounded" />
            <xsd:element ref="delete" maxOccurs="unbounded" />
            <xsd:element ref="loadData" maxOccurs="unbounded" />
            <xsd:element ref="loadUpdateData" maxOccurs="unbounded" />
            <xsd:element ref="executeCommand" maxOccurs="unbounded" />
            <xsd:element ref="stop" maxOccurs="unbounded" />
            <xsd:element ref="rollback" maxOccurs="1" />
            <xsd:any namespace="##other" processContents="lax" minOccurs="0"
                     maxOccurs="unbounded" />
        </xsd:choice>
    </xsd:group>

    <!-- Children for Precondition -->
    <xsd:group name="PreConditionChildren">
        <xsd:sequence>
            <xsd:choice>
                <xsd:element ref="and" maxOccurs="unbounded" />
                <xsd:element ref="or" maxOccurs="unbounded" />
                <xsd:element ref="not" maxOccurs="unbounded" />
                <xsd:element ref="dbms" maxOccurs="unbounded" />
                <xsd:element ref="runningAs" maxOccurs="unbounded" />
                <xsd:element ref="changeSetExecuted" maxOccurs="unbounded" />
                <xsd:element ref="tableExists" maxOccurs="unbounded" />
                <xsd:element ref="columnExists" maxOccurs="unbounded" />
                <xsd:element ref="sequenceExists" maxOccurs="unbounded" />
                <xsd:element ref="foreignKeyConstraintExists" maxOccurs="unbounded" />
                <xsd:element ref="indexExists" maxOccurs="unbounded" />
                <xsd:element ref="primaryKeyExists" maxOccurs="unbounded" />
                <xsd:element ref="viewExists" maxOccurs="unbounded" />
                <xsd:element ref="sqlCheck" maxOccurs="unbounded" />
                <xsd:element ref="changeLogPropertyDefined" maxOccurs="unbounded" />
                <xsd:element ref="expectedQuotingStrategy" maxOccurs="unbounded" />
                <xsd:element ref="customPrecondition" maxOccurs="unbounded" />
                <xsd:any namespace="##other" processContents="lax" minOccurs="0"
                         maxOccurs="unbounded" />
            </xsd:choice>
        </xsd:sequence>

    </xsd:group>
</xsd:schema>



changeset.xml
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
	xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd
        http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
    <changeSet id="3.2_0" author="zchuano"> 
		<tagDatabase tag="3.2" /> 
	</changeSet>
	<changeSet id="3.3_1" author="zchuano" runOnChange="true">
		<preConditions onFail="MARK_RAN" onSqlOutput="TEST">
			 <sqlCheck expectedResult="0">select count(id) from public.auth_resource where id in(1302,1304)</sqlCheck>
		</preConditions>
		<comment>add values in public.auth_resource </comment>
		 <sql>
		    insert into public.auth_resource (id,cname,full_url,status,display) values(1302,'资源列表','/admin/resource/list','true','true'); 
		    insert into public.auth_resource (id,cname,full_url,status,display) values(1304,'修改资源','/admin/resource/edit','true','false'); 
		</sql>
		<rollback>
			<sql>
				delete from public.auth_resource where id = 1302;
				delete from public.auth_resource where id = 1304; 
			</sql>
		</rollback>
	</changeSet>
	<changeSet id="3.3_2" author="zchuano" runOnChange="true">
		<preConditions onFail="MARK_RAN" onSqlOutput="TEST">
            <sqlCheck expectedResult="0">select count(id) from public.auth_model where id in(3)</sqlCheck>
        </preConditions>
        <comment>update public.auth_model resoucrce_ids</comment>
        <sql>
            update public.auth_model set resource_ids = '1001,1101,1201,1301,1302,2201' where id = 3; 
        </sql>
        <rollback>
			<sql>
		    update public.auth_model set resource_ids = '1001,1101,1201,1301,2201' where id = 3; 
			</sql>
		</rollback>
	</changeSet>
	<changeSet id="3.3_3" author="reed" runOnChange="true">
		<preConditions onFail="MARK_RAN" onSqlOutput="TEST">
			<not><columnExists tableName="visit_info" schemaName="crm" columnName="is_again"/></not>
		</preConditions>
        <comment>alter crm.visit_info</comment>
        <addColumn tableName="visit_info" schemaName="crm">
        	<column name="is_again" type="boolean" remarks="是否再次洽谈"></column>
        	<column name="next_time" type="timestamp" remarks="再次洽谈时间"></column>
        	<column name="extend_info" type="VARCHAR(500)" remarks="扩展信息,保存json"></column>
        </addColumn>
        <modifyDataType tableName="visit_info" schemaName="crm" columnName="contactor_phone" newDataType="VARCHAR(60)"/>
        <sql>
        COMMENT ON COLUMN crm.visit_info.is_cooperated IS '拜访结果类型,0,初步沟通、1,暂不合作、2,有合作意向、3,洽谈细节、4,确定合作';        
        </sql>
        <rollback>
        	<dropColumn tableName="visit_info" schemaName="crm" columnName="next_time"/>
        	<dropColumn tableName="visit_info" schemaName="crm" columnName="is_again"/>
        	<dropColumn tableName="visit_info" schemaName="crm" columnName="extend_info"/>
		</rollback>	
	</changeSet>
<!--	<changeSet id="3.3_4" author="liyang" runOnChange="true">
		<preConditions onFail="MARK_RAN" onSqlOutput="TEST">
			 <sqlCheck expectedResult="0">select count(id) from public.auth_resource where id in(1730)</sqlCheck>
		</preConditions>
		<comment>add values in public.auth_resource </comment>
		 <sql>
			insert into public.auth_resource (id,cname,full_url,status,display) values(1730,'合同归档','/contracts/archive/list/*','true','true');
		</sql>
		<rollback>
			<sql>
				delete from public.auth_resource where id = 1730;
			</sql>
		</rollback>
	</changeSet>-->
	<changeSet id="3.3_5" author="zchuano" runOnChange="true">
		<preConditions onFail="MARK_RAN" onSqlOutput="TEST">
            <sqlCheck expectedResult="0">select count(id) from public.auth_resource where id in(1303)</sqlCheck>
        </preConditions>
       <comment>add values in public.auth_resource </comment>
		 <sql>
			insert into public.auth_resource (id,cname,full_url,status,display) values(1303,'添加资源','/admin/resource/add/save','true','false');
		</sql>
		<rollback>
			<sql>
				delete from public.auth_resource where id = 1303;
			</sql>
		</rollback>
	</changeSet>
	<!-- <changeSet id="3.3_6" author="liyang" runOnChange="true">
		<preConditions onFail="MARK_RAN" onSqlOutput="TEST">
			<sqlCheck expectedResult="0">select count(*) from public.auth_model where ','||resource_ids||',' like '%,1730,%' and id = 4</sqlCheck>
		</preConditions>
		<comment>add contracts archive resources to model 4 (合同管理)</comment>
		<sql>
			update public.auth_model set resource_ids=resource_ids ||',1730' where id = 4;
		</sql>
		<rollback>
			<sql>
				update public.auth_model set resource_ids = substring(resource_ids from 1 for (char_length(resource_ids)-char_length(',1730'))) where id = 4;
			</sql>
		</rollback>
	</changeSet> -->
     <changeSet id="3.3_7" author="chenqx" runOnChange="true">
		 <preConditions onFail="MARK_RAN">
			<not><tableExists schemaName="crm" tableName="prepay_transfer"/></not>
			<and>
				<not><tableExists schemaName="history" tableName="prepay_transfer_history"/></not>
			</and>
		</preConditions> 
		<sql>
			CREATE TABLE crm.prepay_transfer
			(
			   id bigserial NOT NULL, 
			   order_sn character varying(50) NOT NULL, 
			   special_id bigint NOT NULL,
			   cont_num character varying(60) NOT NULL, 
			   sp_id bigint NOT NULL,
			   money numeric(10,2) NOT NULL, 
			   prebuy_number bigint ,
			   bank_name character varying(60) NOT NULL, 
			   bank_child_name character varying(200) NOT NULL, 
			   bank_account_number character varying(50) NOT NULL, 
			   bank_account_name character varying(50) NOT NULL, 
			   supplier_mobile character varying(50),
			   bank_province character varying(50) NOT NULL, 
			   bank_city character varying(50) NOT NULL, 
			   author_uid bigint NOT NULL, 
			   payment_uid bigint NOT NULL, 
			   payment_ratio numeric(10,2) , 
			   payment_status smallint NOT NULL DEFAULT 0,
			   payment_time timestamp with time zone ,
			   ctime timestamp with time zone NOT NULL DEFAULT now(), 
			   mtime timestamp with time zone NOT NULL DEFAULT now()
			) 
			WITH (
			  OIDS = FALSE
			)
			;
			ALTER TABLE crm.prepay_transfer
			  ADD CONSTRAINT pk_prepay_transfer PRIMARY KEY(id);
			ALTER TABLE crm.prepay_transfer
	  		  ADD CONSTRAINT "unique_prepay_transfer_odersn" UNIQUE (order_sn);
			ALTER TABLE crm.prepay_transfer
			  OWNER TO crm_cms_owner;
			GRANT ALL ON TABLE crm.prepay_transfer TO crm_cms_owner;
			GRANT SELECT, UPDATE, INSERT ON TABLE crm.prepay_transfer TO group_crm;
			COMMENT ON TABLE crm.prepay_transfer IS '预付款转账记录表';
			COMMENT ON COLUMN crm.prepay_transfer.id         IS 'pk';
			COMMENT ON COLUMN crm.prepay_transfer.order_sn   IS '订单流水号';
			COMMENT ON COLUMN crm.prepay_transfer.special_id IS 'reference: crm.special.id';
			COMMENT ON COLUMN crm.prepay_transfer.cont_num   IS 'reference: crm.contract.cont_num';
			COMMENT ON COLUMN crm.prepay_transfer.sp_id      IS 'reference: crm.supplier.id';
			COMMENT ON COLUMN crm.prepay_transfer.money      IS 'prepay money';
			COMMENT ON COLUMN crm.prepay_transfer.author_uid IS 'reference: crm.special.author_uid';
			COMMENT ON COLUMN crm.prepay_transfer.payment_uid   IS '出纳员工号,cashier-uid';
			COMMENT ON COLUMN crm.prepay_transfer.prebuy_number IS '申请数量,from crm.special.description';
			COMMENT ON COLUMN crm.prepay_transfer.payment_ratio IS '付款比例,from transfer response';
			COMMENT ON COLUMN crm.prepay_transfer.payment_time  IS '实际出款时间,from transfer response';
			COMMENT ON COLUMN crm.prepay_transfer.payment_status IS '打款状态:0-未打款 2-等待银行反馈 3失败 7成功 10退票';
			
			ALTER TABLE crm.prepay_transfer_id_seq
			  OWNER TO crm_cms_owner;
			GRANT ALL ON TABLE crm.prepay_transfer_id_seq TO crm_cms_owner;
			GRANT ALL ON TABLE crm.prepay_transfer_id_seq TO group_crm_cms;
			GRANT SELECT, UPDATE, INSERT ON TABLE crm.prepay_transfer_id_seq TO group_crm;
			
			CREATE TRIGGER trg_prepay_transfer_before_update
			  BEFORE UPDATE
			  ON crm.prepay_transfer
			  FOR EACH ROW
			  EXECUTE PROCEDURE tfun_set_mtime();
			COMMENT ON TRIGGER trg_prepay_transfer_before_update ON crm.prepay_transfer IS 'set column mtime';
			
			CREATE INDEX idx_prepay_transfer_contnum
			  ON crm.prepay_transfer
			  USING btree
			  (cont_num);
			
			CREATE INDEX idx_prepay_transfer_spid
			  ON crm.prepay_transfer
			  USING btree
			  (sp_id);

			CREATE INDEX idx_prepay_transfer_ordersn
			  ON crm.prepay_transfer
			  USING btree
			  (order_sn);
			
			CREATE TABLE history.prepay_transfer_history
			(
			   dbuser character varying(50),
               userip cidr,
			   id bigint NOT NULL, 
			   order_sn character varying(50) NOT NULL, 
			   special_id bigint NOT NULL,
			   cont_num character varying(60) NOT NULL, 
			   sp_id bigint NOT NULL,
			   money numeric(10,2) NOT NULL, 
			   prebuy_number bigint ,
			   bank_name character varying(60) NOT NULL, 
			   bank_child_name character varying(200) NOT NULL, 
			   bank_account_number character varying(50) NOT NULL, 
			   bank_account_name character varying(50) NOT NULL, 
			   supplier_mobile character varying(50),
			   bank_province character varying(50) NOT NULL, 
			   bank_city character varying(50) NOT NULL, 
			   author_uid bigint NOT NULL, 
			   payment_uid bigint NOT NULL, 
			   payment_ratio numeric(10,2) , 
			   payment_status smallint NOT NULL,
			   payment_time timestamp with time zone ,
			   ctime timestamp with time zone NOT NULL DEFAULT now(), 
			   mtime timestamp with time zone NOT NULL DEFAULT now()
			) 
			WITH (
			  OIDS = FALSE
			)
			;
			ALTER TABLE history.prepay_transfer_history
			  OWNER TO crm_cms_owner;
			GRANT ALL ON TABLE history.prepay_transfer_history TO crm_cms_owner;
			GRANT SELECT, UPDATE, INSERT ON TABLE history.prepay_transfer_history TO group_crm_cms;
			GRANT SELECT, UPDATE, INSERT ON TABLE history.prepay_transfer_history TO group_crm;
			COMMENT ON TABLE history.prepay_transfer_history IS '预付款转账记录历史表';
			
			CREATE INDEX idx_prepay_transfer_history_ordersn
			  ON history.prepay_transfer_history
			  USING btree
			  (order_sn);
			
			CREATE OR REPLACE FUNCTION crm.tfun_after_prepay_transfer() RETURNS trigger AS ' begin insert into history.prepay_transfer_history  values(user,inet_client_addr(),NEW.*); return NEW ;end;'LANGUAGE plpgsql ;
			ALTER FUNCTION crm.tfun_after_prepay_transfer()
		  		OWNER TO crm_cms_owner;
		
			CREATE TRIGGER trg_prepay_transfer_after
			  AFTER INSERT OR UPDATE
			  ON crm.prepay_transfer
			  FOR EACH ROW
			  EXECUTE PROCEDURE crm.tfun_after_prepay_transfer();
			COMMENT ON TRIGGER trg_prepay_transfer_after ON crm.prepay_transfer IS '插入或更新后,记录历史流水表';
		</sql>
		<rollback>
			<dropTable schemaName="history" tableName="prepay_transfer_history"/>
			<dropTable schemaName="crm" tableName="prepay_transfer"/>
		</rollback>
	</changeSet>
	<changeSet id="3.3_8" author="zchuano" runOnChange="true">
		<preConditions onFail="MARK_RAN" onSqlOutput="TEST">
			 <sqlCheck expectedResult="0">select count(id) from public.auth_resource where id in(1305,1306,1307)</sqlCheck>
		</preConditions>
		<comment>add values in public.auth_resource </comment>
		 <sql>
		    insert into public.auth_resource (id,cname,full_url,status,display) values(1305,'模块列表','/admin/model/list','true','true'); 
		    insert into public.auth_resource (id,cname,full_url,status,display) values(1306,'更新模块','/admin/model/updateresource/*','true','false'); 
		    insert into public.auth_resource (id,cname,full_url,status,display) values(1307,'禁用模块','/admin/model/disablemodel/*','true','false'); 
		</sql>
		<rollback>
			<sql>
				delete from public.auth_resource where id = 1305;
				delete from public.auth_resource where id = 1306; 
				delete from public.auth_resource where id = 1307; 
			</sql>
		</rollback>
	</changeSet>
	<changeSet id="3.3_9" author="zchuano" runOnChange="true">
		<preConditions onFail="MARK_RAN" onSqlOutput="TEST">
            <sqlCheck expectedResult="0">select count(id) from public.auth_model where id in(3)</sqlCheck>
        </preConditions>
        <comment>update public.auth_model resoucrce_ids</comment>
        <sql>
            update public.auth_model set resource_ids = '1001,1101,1201,1301,1302,1305,2201' where id = 3; 
        </sql>
        <rollback>
			<sql>
		    update public.auth_model set resource_ids = '1001,1101,1201,1301,1302,2201' where id = 3; 
			</sql>
		</rollback>
	</changeSet>
	<changeSet id="3.3_10" author="alvin" runOnChange="true">
        <comment>update crm.contract lrname </comment>
        <sql>
            ALTER TABLE crm.contract ALTER COLUMN lrname TYPE character varying(50);
        </sql>
	</changeSet>
	<changeSet id="3.3_11" author="alvin" runOnChange="true">
        <comment>update crm.contract lrname </comment>
        <sql>
            ALTER TABLE history.contract_history ALTER COLUMN lrname TYPE character varying(50);
        </sql>
	</changeSet>
	<changeSet id="3.3_12" author="chenqx" runOnChange="true">
		<preConditions onFail="MARK_RAN" onSqlOutput="TEST">
			<sqlCheck expectedResult="电子券类型">
				select c.description from pg_attribute a ,pg_class b,pg_description c
                   where a.attrelid = b.oid  and c.objoid = b.oid and c.objsubid = a.attnum  
                   and b.relname='deal' and a.attname = 'e_voucher_type'
			</sqlCheck>
		</preConditions>
		<comment>fix comments on column</comment>
		<sql>
			COMMENT ON column crm.contract.status is '状态,refer to public.data_dictionary.[crm.contract.status]';
			COMMENT ON column crm.contract.source is '来源,refer to public.data_dictionary.[crm.contract.source]';
			COMMENT ON column crm.contract_bank.source is '来源,refer to public.data_dictionary.[crm.contract_bank.source]';
			COMMENT ON column crm.contract_bank.bank_account_type is '账户类型,refer to public.data_dictionary.[crm.contract_bank.bank_account_type]';
			COMMENT ON column crm.contract_child.status is '状态,refer to public.data_dictionary.[crm.contract_child.status]';
			COMMENT ON column crm.contract_child.source is '来源,refer to public.data_dictionary.[crm.contract.source]';
			COMMENT ON column crm.contract_child.payment_type is '付款方式,refer to public.data_dictionary.[crm.contract_child.payment_type]';
			COMMENT ON column crm.supplier.status is '状态,refer to public.data_dictionary.[crm.supplier.status]';
			COMMENT ON column crm.merchant.source is '来源,refer to public.data_dictionary.[crm.contract.source]';
			COMMENT ON column crm.supplier_qualification.source is '来源,refer to public.data_dictionary.[crm.contract.source]';
			COMMENT ON column crm.visit_info.source is '来源,refer to public.data_dictionary.[crm.contract.source]';
			COMMENT ON column crm.special.status is '状态,refer to public.data_dictionary.[crm.special.status]';
			COMMENT ON column crm.special.source is '来源,refer to public.data_dictionary.[crm.contract.source]';
			COMMENT ON column crm.special.payment_type is '付款方式,refer to public.data_dictionary.[crm.special.payment_type]';
			COMMENT ON column crm.special.prepay_type is '预付类型,refer to public.data_dictionary.[crm.special.prepay_type]';
			COMMENT ON column cms.deal.status is '状态,refer to public.data_dictionary.[cms.deal.status]';
			COMMENT ON column cms.deal.e_voucher_type is '电子券类型,refer to public.data_dictionary.[cms.deal.e_voucher_type]';
		</sql>
	</changeSet>
</databaseChangeLog>

你可能感兴趣的:(demo)