Liquibase duplicate identifiers using inclueAll tag - include

I'm new to liquibase and trying to setup a working solution for our software. At the moment i'm struggling with the 'includeAll' tag for the master changelog.
If i'm using includeAll it allways says:
Validation Error:
1 change sets had duplicate identifiers
install/data/changelog-data.xml::1::wild.a
Liquibase 'validate' Successful
The whole files to reproduce are included in the database.zip which can be downloaded here:
https://docs.google.com/file/d/0B8W-n_j7omQ4UUhzQjdrdnlMdk0/edit?usp=sharing
You only have to modify liquibase.properties.
The curious thing is that the following line work:
<include relativeToChangelogFile="true" file="install/data/changelog-data.xml"/>
While this line won't work:
<includeAll relativeToChangelogFile="true" path="install/data/"/>
The question is how to use includeAll to work without having duplicate identifiers.
Thanks in advance.

It is a bug in 3.0.0 that has been fixed in 3.0.2.

Related

Specifying files by absolute path was removed in Liquibase 4.0

I am getting the following liquibase error when I run my Spring Boot application:
Specifying files by absolute path was removed in Liquibase 4.0. Please use a relative path or add '/' to the classpath parameter.
Here is the class path in application.yaml:
liquibase:
change-log: classpath:db/changelog/db-changelog-master.xml
I also tried:
liquibase:
change-log: classpath:/db/changelog/db-changelog-master.xml
Here is folder structure:
Changlog master:
<?xml version="1.0" encoding="UTF-8"?>
<databaseChangeLog
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd">
<include file="db-changelog-1.0.xml"/>
</databaseChangeLog>
I got this issue when putting the changelog files outside the resources folder, but if I include them under resources/db/changelog, then it would work fine with setting the bellow config.
spring.liquibase.change-log=classpath:/db/changelog/changelog-master.xml
Tested under 4.6.2
This is still an open issue unfortunately. See 2281.
Looks like this was fixed in v4.4.3
As explained here
How the Liquibase classpath worked before version 4.0
Before version 4.0, one of the default locations Liquibase added to
the classpath was the root directory in your filesystem (/). The
change caused issues because of a machine-dependent changelog path,
such as /home/my-user/projects/liquibase/changelog.xml, found under
the / directory. This way, Liquibase uses the given path as part of
the changeset identifier stored in the DATABASECHANGELOG table, and
when you run Liquibase from
/home/other-user/projects/liquibase/changelog.xml, Liquibase sees it
as a different changelog and tries to rerun all the previously run
changesets.
To prevent identification issues from happening, a / was removed as a
default part of the classpath. How the Liquibase classpath works in
4.0 and later versions
Starting with Liquibase 4.0, the root directory (/) is no longer a
default part of the classpath because of the issue mentioned in the
previous section.
...
The message "Please use a relative path or add '/' to the classpath parameter." refers to the root directory '/', and does not mean to add a slash to the start of your classpath path. Afaik, classpath:x and classpath:/x are the same.
Also, the message appears when the master changelog is not found, for whatever reason, so also a typo can cause this message. It's only a hint telling you that it might not be found because the file is not on the classpath, because they removed the root directory from the classpath, but it could also not be found because you specified the wrong path (I just did that).
To configure it correctly, the master changelog must be on the Liquibase classpath. In Spring Boot, the Liquibase classpath is set to the application's classpath, i.e. you can use src/main/resources.
Tl;dr: When your file is src/main/resources/db/changelog/db.changelog-master.xml use
spring.liquibase.change-log=classpath:/db/changelog/db.changelog-master.xml
I don't know, whether there was or is a bug in regards to that with certain Liquibase versions, but that's how it's supposed to work, anyway.
Just try to remove "classpath:" from "change-log:" parameter.
Also try to check your pom.xml ("changeLogFile" tag in configuration):
there should not be a "${basedir}" before change log file path.
<changeLogFile>
/src/main/resources/liquibase/changelog.xml
</changeLogFile>

Getting project root in Liquibase sql changeset

I have a requirement in my project where I want to read files into table CLOB data. The database is oracle 12g. We are using liquibase to maintain the data.
The project is in springboot. Liquibase uses .sql files to load changes.
The hurdle I am facing is that sql needs the absolute path to the file rather than the path relative to the current changeset file.
Any pointers about how I can use a "." or the "classpath:" in the sql of the changeset?
One of the attempts I have made are sending a property in the changeset through the property tag withen the databaseChangeLog tag. Values of such properties are available in the changeset file, but they dont interpret placeholders like "classpath:". Hence I am stuck.
The
dbms_lob.fileopen
only accepts a directory object with the absolute path. No "." etc is understood. The . in a filepath starts at the database installation root which is of no use to me. I would like the path to where all the changeset files are stored.
Please help If you have solved this in any way..
I will post more details if required..
Appreciate the help..
As example what work for me: i'va put this argument on command line as reference for the master changelog
--changeLogFile=src/main/resources/changelog/db.changelog-master.xml
and in the master file
<include file="./changes/db.changelog-ddl-.....xml" relativeToChangelogFile="true"/>
It will be the same for sql file in changeset - they will be referenced relative to the .xml
What about setting up a directory object in oracle in advance and then use symbolic linking on OS level. Depending on your exact requirements you can use symbolic linking on directory level, or you can even directly link the files into the oracle directory, so that Oracle can see files from many different directories at once in the directory object. They need to have different filenames then. I have not tried this idea, but I guess this approach is what I would try out first. HTH KR
Liquibase supports properties in changelogs that can be set in various ways - more information:
http://www.liquibase.org/documentation/changelog_parameters.html
Here is a snippet of that documentation:
Liquibase allows dynamic substitution of parameters in a changelog.
The parameters to replace are described using the ${} syntax.
Parameter values are looked up in the following order:
Passed as a parameter to your Liquibase runner (see Ant, command_line, etc. documentation for how to pass them)
As a JVM system property
In the parameters block ( Tag) of the DatabaseChangeLog file itself.
Example of how could be used:
<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-2.0.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<property name="clob.type" value="clob" dbms="oracle"/>
<property name="clob.type" value="longtext" dbms="mysql"/>
<changeSet id="1" author="joe">
<createTable tableName="table1">
<column name="id" type="int"/>
<column name="${columnname}" type="varchar(20)"/>
</createTable>
</changeSet>
easily you can set file path inside SQL change-set via a property while property value passed with JVM or Build-tools.
#echo off
call Liquibase --changeLogFile=myChangeLogFile.xml update -Dcolumnname=myclm
However I think you can use ${java.class.path} without set it's value from outside.

Phonegap build error for windows

I am trying to create a build for windows using here where as was following this same method till last week.
unfortunately today I am getting error as below,
Any suggestion please.
Don't use CLI if you are using Build.
Try to install the plugin again
cordova plugin add cordova-plugin-vibration
I had the same isue. I solved the problem that I had excluded all plugins from xml except on and then I tried to build. After every succesful build I include new plugin, then I came to the error.
You have wrong plugin for vibration in xour xml:
your plugin :
<plugin name="org.apache.cordova.vibration"/>
replace it with this:
<plugin name="org.apache.cordova.vibration" spec="0.3.13" source="pgb" />
Tell me if it works?
Regards, Ivan

Liquibase executes changeset several times in single Maven build

I am observing some strange Liquibase behavior when I run simple Maven project on TeamCity build agent.
Maven project structure:
changelogs/
databaseChangeLog.xml
pom.xml
Run command: mvn liquibase:update
databaseChangeLogs.xml contains next line: <includeAll path="changelogs/"/>
But build log contains duplication records:
liquibase: databaseChangeLog.xml: /home/teamcity/BuildAgent/work/28fe713da351c06d/changelogs/1.xml: ChangeSet /home/teamcity/BuildAgent/work/28fe713da351c06d/changelogs/1.xml ran successfully in 40ms
liquibase: databaseChangeLog.xml: Custom SQL executed
liquibase: databaseChangeLog.xml: changelogs/1.xml: ChangeSet changelogs/1.xml ran successfully in 36ms
So seems like Liquibase picked up changeset twice from different locations: from build agent's build folder and root of the project.
Does anybody meet the same issue?
Any ideas how to fix this?
Liquibase has kinda a design flaw which lays in considering at our first glance "identical" change sets as different. To bypass such a peculiarity you can use logicalFilePath attribute either on databaseChangeLog tag or on every changeSet tag. This one will add another level of identity, uniqueness to a your change set.

uglify-maven-plugin adding exclude file list

I am trying to implement uglifyjs-maven-plugin.
While using the configuration mentioned here, I am getting error like sourceDirectory is undefined or invalid.
Using the configuration like
<configuration>
<sourceDirectory>target/snapshot/javascript</sourceDirectory>
<outputDirectory>target/snapshot/javascript</outputDirectory>
</configuration>
its working fine. But how will I add exclude file list in the above configuration.
I have a js file of 900kb, when i am including that js file inside source directory, i am getting exception during maven build as " Exception in thread "main" java.lang.StackOverflowError". Can anyone help me out of this.
It looks like that while the documentation (and probably the current implementation) supports file exclusions, the version available in the repository (1.0) is older and supports only sourceDirectory.
I have not found any newer version published anywhere, so I guess the best thing we can do is compile the latest version of the plugin manually and see if it supports what the documentation says.

Resources