Quantcast
Channel: Liquibase Forums
Viewing all 1169 articles
Browse latest View live

Re : Validation Failed without any changes

$
0
0
Good, thanks for letting me know.

Nathan

Liquibase MySQL “DateTime(3)” Not Work

$
0
0
I was trying to create a MySQL table with a column type "DateTime(3)" by using Liquibase changelog, e.g. <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.

Commit each statement with "Go"

$
0
0
Forgive the SQL newbie here. DBA stated we needed to commit each statement with a GO. It works from TSQL in management studio, just not liquibase. Any help is appreciated. 

Example

Drop column table 1 
GO

Drop column table 2 
GO

Tried 
<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>


Error using YAML format

$
0
0
Hi, I'm using liquibase 3.5.4 on fedora 26, and I trying to use YAML format but I get this error in a update command:

SEVERE 12/04/18 11:53: liquibase: org.yaml.snakeyaml.Yaml
java.lang.NoClassDefFoundError: org/yaml/snakeyaml/Yaml
    at liquibase.parser.core.yaml.YamlChangeLogParser.parse(YamlChangeLogParser.java:23)
    at liquibase.Liquibase.getDatabaseChangeLog(Liquibase.java:229)
    at liquibase.Liquibase.update(Liquibase.java:202)
    at liquibase.Liquibase.update(Liquibase.java:192)
    at liquibase.integration.commandline.Main.doMigration(Main.java:1130)
    at liquibase.integration.commandline.Main.run(Main.java:188)
    at liquibase.integration.commandline.Main.main(Main.java:103)
Caused by: java.lang.ClassNotFoundException: org.yaml.snakeyaml.Yaml
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 7 more

I have the file "snakeyaml-1.17.jar" in the lib folder but it seems that is not read. I try to change permissions (read, execution...) but nothing change. In xml format works great.

With version 3.6.1 I have a similar error:

Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.NoClassDefFoundError: ch/qos/logback/core/filter/Filter
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
        at java.lang.Class.privateGetMethodRecursive(Class.java:3048)
        at java.lang.Class.getMethod0(Class.java:3018)
        at java.lang.Class.getMethod(Class.java:1784)
        at sun.launcher.LauncherHelper.validateMainClass(LauncherHelper.java:544)
        at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:526)
Caused by: java.lang.ClassNotFoundException: ch.qos.logback.core.filter.Filter
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:338)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 7 more

I also have the corrects files (logback-classic-1.2.3.jar, logback-core-1.2.3.jar, slf4j-api-1.7.25.jar, snakeyaml-1.18.jar) in the lib folder. In this version no command works.

Any idea? Thanks.

Re : Error using YAML format

$
0
0
The first thing I would check is the liquibase shell script. It uses or sets a variable LIQUIBASE_HOME - you might add or uncomment some things in that shell script to ensure it is using the locations and jars you think it should be using. 

I'll sometimes change the last few lines of that shell script to look like this:

  1. MY_CMD="java -cp \"$CP\" $JAVA_OPTS liquibase.integration.commandline.Main ${1+\"$@\"}"
  2. echo $MY_CMD
  3. $MY_CMD
This is basically the same as the default last line, but set into a variable. It has to be quoted, so the existing double quotes have to be escaped. It then echos the command and then executes it, making it easy to see what the classpath being used is.

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

Re : [Solved] Error using YAML format

$
0
0
The problem was in runnig the application from the .jar with the command:

java -jar <path-to-liquibase-jar>

The liquibase command solve the error.


Thanks for the help.

Liquibase changing type of primary key

$
0
0

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.

Re : [Solved] Error using YAML format


Liquibase and several schemas best practices

$
0
0
I am using Liquibase on DB with several schemas. Those schemas has foreign keys to each other.
What is a best practise for such use case with Liquibase?

Currently migration files are separated in folders by schema. Each schema has its own changeset-master.xml. 
In this case I loose ability to create schema from scratch. Creating FK to other schemas should be preconditioned "CONTINUE" to columnExists and created on second run.

Is it better to have one big changeset-master.xml for the whole DB? In this case, where to place tables databasechangelog and databasechangeloglock?

Re : Liquibase changing type of primary key

$
0
0
Hi Adam,

it could be that the RDBMS-specific code for that has changed. Can you tell me which RDBMS (PostgreSQL/MariaDB/MSSQL/...) you are using, which Liquibase version the old behaviour showed, and since which Liquibase version you are seeing the different data type?

Kind regards,
Andreas

Re : Liquibase changing type of primary key

$
0
0
Hi Andreas,

Thanks for the reply. I'm using MariaDB and the latest version of Liquibase. I'm currently testing Liquibase for use at my place of work so have no previous version. The changelogs are generated from the Liquibase command.

Adam

Re : Liquibase changing type of primary key

$
0
0
Had a look at this again this morning and managed to fix this by changing the columnDataType to SMALLINT(5) UNSIGNED in the addAutoIncrement section. Seems to be working as intended now. Probably user error to be honest.

Re : Liquibase changing type of primary key

$
0
0
Ok, just so that I have a test case I can reproduce the problem with, can you post:

1. The CREATE TABLE-Statement of the table (in the state before the change set runs)
2. The relevant part of your changelog/changeset

Re : How can I disable logging in tests?

$
0
0
Finally figured it out.

I had Logback on the classpath, so to disable it I had to set the log level in Logback instead of on the logger instance because the setLogLevel() method in Slf4jLogger no-ops.

I basically did before running my Liquibase test command.

val logger = LoggerFactory.getLogger("liquibase")
(logger as ch.qos.logback.classic.Logger).level = Level.ERROR

File path issue with maven-plugin

$
0
0
Liquibase Version: 3.6.1/3.6.0
Database: SQLite/Oracle
OS: Windows 7

When I run "mvn liquibase:update" getting error, same setup working fine with command line SDK.

Error setting up or running Liquibase: liquibase.exception.SetupException: liquibase.exception.SetupException: File does not exist: file:/release1/ddl/001_SAMPLE.sql

directory structure:
  1. │   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
pom.xml
  1. <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>

db-changelog-master.xml

release/db-changelog-1.0.xml
  1. <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>

liquibase.properties
  1. driver: org.sqlite.JDBC
    url: jdbc:sqlite:sampledb.db


mvn liquibase:update

  1. >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

Re : File path issue with maven-plugin

$
0
0
Thie issue appears to be that it is trying to access the files using an absolute path:

  1. file:/release1/ddl/001_SAMPLE.sql

rather than 

  1. file:/C:/some_path_to_project/release1/ddl/001_SAMPLE.sql

It isn't clear from the documentation, but looking at the code it looks like it might be possible to have an attribute 'relativeToChangelogFile' on that element.

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

Cannot use array on h2 with liquibase while in postgres works perfectly

$
0
0
Hello,

I'm using this change set:

 <changeSet author="marco_scarpa" id="pg-101" dbms="postgresql, h2"
               failOnError="false">
        <createTable tableName="SYM_NAMES">
            <column name="label" type="VARCHAR(255)">
                <constraints nullable="false" primaryKey="true"/>
            </column>
            <column name="profile_pallet" type="VARCHAR(255)">
                <constraints nullable="false" primaryKey="true"/>
            </column>
            <column name="mandante" type="VARCHAR(64)">
                <constraints nullable="false" primaryKey="true"/><!-- potrebbero esserci diversi mandanti che creano aree diverse -->
            </column>
            <column name="unit" type="VARCHAR(255)">
                <constraints nullable="true"/><!-- in generale i nomi simbolici potrebbero non essere associati a pallet -->
            </column>
            <column  name="sym_name_values" type="VARCHAR(255) ARRAY" defaultValue="NULL">
                <constraints nullable="true"/>
            </column>
        </createTable>
    </changeSet>

In postgres the array is correctly created (i got INFO 07/05/18 19.07: liquibase: classpath:/db/changelog/db.changelog-master.xml: classpath:/db/changelog/db.changelog-master.xml::pg-101::marco_scarpa: Table SYM_NAMES created
INFO 07/05/18 19.07: liquibase: classpath:/db/changelog/db.changelog-master.xml: classpath:/db/changelog/db.changelog-master.xml::pg-101::marco_scarpa: ChangeSet classpath:/db/changelog/db.changelog-master.xml::pg-101::marco_scarpa ran successfully in 263ms).

In h2 i get such error:

INFO 07/05/18 19.19: liquibase: classpath:/db/changelog/db.changelog-master.xml: classpath:/db/changelog/db.changelog-master.xml::pg-101::marco_scarpa: Change set classpath:/db/changelog/db.changelog-master.xml::pg-101::marco_scarpa failed, but failOnError was false.  Error: Syntax error in SQL statement "CREATE TABLE PUBLIC.SYM_NAMES (LABEL VARCHAR(255) NOT NULL, PROFILE_PALLET VARCHAR(255) NOT NULL, MANDANTE VARCHAR(64) NOT NULL, UNIT VARCHAR(255), SYM_NAME_VALUES VARCHAR(255) ARRAY[*] DEFAULT NULL, CONSTRAINT PK_SYM_NAMES PRIMARY KEY (LABEL, PROFILE_PALLET, MANDANTE)) "; expected "FOR, UNSIGNED, NOT, NULL, AS, DEFAULT, GENERATED, NOT, NULL, AUTO_INCREMENT, BIGSERIAL, SERIAL, IDENTITY, NULL_TO_DEFAULT, SEQUENCE, SELECTIVITY, COMMENT, CONSTRAINT, PRIMARY, UNIQUE, NOT, NULL, CHECK, REFERENCES, ,, )"; SQL statement:
CREATE TABLE PUBLIC.SYM_NAMES (label VARCHAR(255) NOT NULL, profile_pallet VARCHAR(255) NOT NULL, mandante VARCHAR(64) NOT NULL, unit VARCHAR(255), sym_name_values VARCHAR(255) ARRAY DEFAULT null, CONSTRAINT PK_SYM_NAMES PRIMARY KEY (label, profile_pallet, mandante)) [42001-191] [Failed SQL: CREATE TABLE PUBLIC.SYM_NAMES (label VARCHAR(255) NOT NULL, profile_pallet VARCHAR(255) NOT NULL, mandante VARCHAR(64) NOT NULL, unit VARCHAR(255), sym_name_values VARCHAR(255) ARRAY DEFAULT null, CONSTRAINT PK_SYM_NAMES PRIMARY KEY (label, profile_pallet, mandante))]

It looks it adds randomly ARRAY[*] to the query and I don't know why.

Can I Load Metadata with DataLoad

$
0
0
I am wanting to import a CSV of data that contains data attributes from varying datasets. I also have accompanying metadata that I would like to include in the LoadData. Is there a way to accomplish this? I have tried and failed to do so. 

For example:
      <changeSet id="201805070230-1-load-toams-zones-table-attributes" author="powers_rc">
    <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>

Re : Can I Load Metadata with DataLoad

$
0
0
It is not clear from your question what metadata you want to load, what you have tried, what your expected results were or what the actual results were. "I have tried and failed" just isn't descriptive enough.

Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/

Re : Can I Load Metadata with DataLoad

$
0
0
Sorry about that. I have updated my question with a little more detail. Please let me know if you can now understand what I am asking. 

Thanks.
Viewing all 1169 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>