Good, thanks for letting me know.
Nathan
Nathan
<column name="dateTimeColumn" type="DateTime(3)">
. However, The output of data type is always "DateTime" (Fractional seconds disappered). But, when I changed the type to "Timestamp(3)", it worked. Anyone know what is the problem ? Please advice.
<sql endDelimiter="\nGO" splitStatements="true">
Drop column table 1
Drop column table 2
</sql>
Try 2
<sql endDelimiter="GO" splitStatements="true">
Drop column table 1
Drop column table 2
</sql>
Try 3
<sql>
Drop column table 1
Drop column table 2
</sql>
Try 4
<sql endDelimiter="GO" splitStatements="true">
Drop column table 1 GO
Drop column table 2 GO
</sql>
Having generated a changelog on a current database, I have attempted to create a new database from that changelog. After a fair few problems probably related to our database structure, I've come across some strange behaviour.
When adding a primary key to a table consisting of two columns, the type of the column is changed from smallint(5) to int(11).
When adding a foreign key later in the script, this fails as the type of the two tables does not match anymore.
Any information as to why liquibase does that and how to prevent it from changing the type when adding a primary key? I can't find any mention of it in the docs or any other mention of this behaviour online.
val logger = LoggerFactory.getLogger("liquibase")
(logger as ch.qos.logback.classic.Logger).level = Level.ERROR
│ db-changelog-master.xml │ liquibase.properties │ pom.xml │ └───release1 │ db-changelog-1.0.xml │ ├───ddl │ 001_SAMPLE.sql │ └───dml 002_SAMPLE.sql 003_SAMPLE.sql
<build> <plugins> <plugin> <groupId>org.liquibase</groupId> <artifactId>liquibase-maven-plugin</artifactId> <version>3.6.1</version> <configuration> <changeLogFile>db-changelog-master.xml</changeLogFile> <verbose>true</verbose> <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase> <propertyFile>liquibase.properties</propertyFile> </configuration> </plugin> </plugins> </build>
<?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 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"> <include file="release1/db-changelog-1.0.xml" relativeToChangelogFile="true"/> </databaseChangeLog>
<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-3.6.xsd"> <includeAll path="release1/ddl/" errorIfMissingOrEmpty="true" /> <includeAll path="release1/dml/" errorIfMissingOrEmpty="true" /> </databaseChangeLog>
driver: org.sqlite.JDBC url: jdbc:sqlite:sampledb.db
>mvn liquibase:update [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building database-script 1.0.0 [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- liquibase-maven-plugin:3.6.1:update (default-cli) @ database-script --- [INFO] ------------------------------------------------------------------------ [INFO] Loading artifacts into URLClassLoader [INFO] artifact: file:/C:/Users/Public/Documents/maven/repository/org/xerial/sqlite-jdbc/3.21.0.1/sqlite-jdbc-3.21.0.1.jar [INFO] artifact: file:/C:/Users/pateman/code/liquibase/db1/maven/target/classes [INFO] artifact: file:/C:/Users/pateman/code/liquibase/db1/maven/target/test-classes [INFO] ------------------------------------------------------------------------ [INFO] Parsing Liquibase Properties File [INFO] File: liquibase.properties [INFO] ------------------------------------------------------------------------ [INFO] Starting Liquibase at Wed, 18 Apr 2018 11:59:58 IST (version 3.6.1 built at 2018-04-11 09:05:04) [INFO] Settings ---------------------------- [INFO] driver: org.sqlite.JDBC [INFO] url: jdbc:sqlite:sampledb.db [INFO] username: null [INFO] password: ***** [INFO] use empty password: false [INFO] properties file: liquibase.properties [INFO] properties file will override? false [INFO] prompt on non-local database? false [INFO] clear checksums? false [INFO] changeLogDirectory: null [INFO] changeLogFile: db-changelog-master.xml [INFO] context(s): null [INFO] label(s): null [INFO] number of changes to apply: 0 [INFO] drop first? false [INFO] ------------------------------------------------------------------------ [INFO] Executing on Database: jdbc:sqlite:sampledb.db [INFO] SELECT COUNT(*) FROM DATABASECHANGELOGLOCK [INFO] CREATE TABLE DATABASECHANGELOGLOCK (ID INTEGER NOT NULL, LOCKED BOOLEAN NOT NULL, LOCKGRANTED TEXT, LOCKEDBY VARCHAR(255), CONSTRAINT PK_DATABASECHANGELOGLOCK PRIMARY KEY (ID)) [INFO] SELECT COUNT(*) FROM DATABASECHANGELOGLOCK [INFO] DELETE FROM DATABASECHANGELOGLOCK [INFO] INSERT INTO DATABASECHANGELOGLOCK (ID, LOCKED) VALUES (1, 0) [INFO] SELECT LOCKED FROM DATABASECHANGELOGLOCK WHERE ID=1 [INFO] Successfully acquired change log lock [INFO] Successfully released change log lock [INFO] ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.202 s [INFO] Finished at: 2018-04-18T12:00:00+05:30 [INFO] Final Memory: 10M/142M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.6.1:update (default-cli) on project database-script: Error setting up or running Liquibase: liquibase.exception.SetupException: liquibase.exception.SetupException: Fi le does not exist: file:/release1/ddl/001_SAMPLE.sql -> [Help 1] [ERROR] [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch. [ERROR] Re-run Maven using the -X switch to enable full debug logging. [ERROR] [ERROR] For more information about the errors and possible solutions, please read the following articles: [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
<loadData encoding="UTF-8"
file="file/path/to/ZONES.csv"
quotchar='"'
schemaName="test"
separator=","
tableName="data_schema">
<column name="id" type="SKIP"/>
<column name="dataset_name" defaultValue="ZONES" type="STRING"/>
<column name="collection_effort" defaultValue="Q22018 Data Inventory" type="STRING"/>
<column name="information_source" defaultValue="Person 1" type="STRING"/>
<column name="reported_by" defaultValue="Person 2" type="STRING"/>
<column name="reported_date" defaultValue="2018-05-03" type="DATE"/>
<column name="captured_date" defaultValue="2018-05-07" type="DATE"/>
<!--<column name="name" header="Column Name" type="STRING"/>-->
<column name="column_name" header="Column Name" type="STRING"/>
<column name="data_type" header="name" type="STRING"/>
<column name="length" header="Max Length in Bytes" type="STRING"/>
<column name="operational_status" defaultValue="Active" type="STRING"/>
<column name="operational_datetime" defaultValue="2018-05-07" type="DATE"/>
<column header="DDL name" type="SKIP"/>
<column header="precision" type="SKIP"/>
<column header="scale" type="SKIP"/>
<column header="is_nullable" type="SKIP"/>
<column header="Primary Key" type="SKIP"/>
</loadData>
</changeSet>