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

ServiceLocator/classpath scanning does not work when wrapped in an EXE


Rollback of primary key with named index doesn't work

$
0
0
Hello!

I run liquibase against an oracle 11g databas, I have a primary key based on a unique index
when i try to rollback i get

ORA-01418: specified index does not exist
 [Failed SQL: DROP INDEX Table.T_PK]

when i checked SQL generated by rollback i discovered that two command generated by liquibase the first drops the primary key with the index then the second command tries to delete an index with doesn't exist.

  ALTER TABLE schema.table DROP PRIMARY KEY DROP INDEX;
 
  DROP INDEX schema.T_PK;

any suggestions to come around this issue or is it going to be fixed in 3.5.2?


Regards
Raste

Macro for repeated/common table column definitions

$
0
0
Hi Folks,

I have a number of separate database tables which contain their own unique column definitions - however they do contain a small number of columns which share the same definition across all the tables - I was wondering if Liquibase supports any sort of re-usable column macro which allows you to define a number of re-usable columns in one place in a changelog and then easily add these columns to one or more tables without having to repeat the column definitions over and over again?

Shane

Liquibase Update/Rollback for Function does not work

$
0
0
Trying to update an existing SQL function, the SQL code is correct (have run it directly on the database) but cannot get Liquibase to run it successfully, or roll it back :(

Liquibase says 'Migration Successful' on update but nothing is changed in the DB, and 'Migration Failed: Unknown Reason' on rollback.
<?xml version="1.0" encoding="UTF-8"?>

<databaseChangeLog
        xmlns="http://www.liquibase.org/xml/ns/dbchangelog/1.7"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog/1.7 http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-1.7.xsd">
    
  <changeSet id="00" author="johnsmith">
    <sql splitStatements="false">
DROP FUNCTION dummy(text, text, text);
CREATE OR REPLACE FUNCTION dummy(var1 text, var2 text, var3 text, newvar1 text)
  RETURNS void AS
$BODY$

/*
does new stuff here
*/
    RETURN;

END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION dummy(text, text, text, text) OWNER TO bob;

	</sql>
    <rollback>
DROP FUNCTION dummy(text, text, text, text);
CREATE OR REPLACE FUNCTION dummy(var1 text, var2 text, var3 text)
  RETURNS void AS
$BODY$
/*
do old stuff here
*/
    RETURN;

END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE;
ALTER FUNCTION dummy(text, text, text) OWNER TO bob;
    </rollback>
  </changeSet>
</databaseChangeLog>

DatabaseException for liquibase Update

$
0
0
I am getting the following error while running liquibase Update on MYSQL

Error:
 Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.1:update (default-cli) on project liqui-demo: Error setting up or running Liquibase: Migration failed for change set src/main/resources/initialSchema.xml::0.0_3::Salil:
[ERROR] Reason: liquibase.exception.DatabaseException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 1 [Failed SQL: DELIMITER]
[ERROR] 

Script:

DELIMITER ;;
CREATE FUNCTION `functionname`(
Idname BIGINT(20)
) RETURNS bit(1)
BEGIN


Pom file:

<modelVersion>4.0.0</modelVersion>
<groupId>com.salil.liquibase</groupId>
<artifactId>liqui-demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>liqui-demo</name>

<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
<propertyFile>src/main/resources/param.properties</propertyFile>
<migrationSqlOutputFile>
${project.build.directory}/liquibase/migrate-${projectname.dbName}-${projectname.environment}.sql
</migrationSqlOutputFile>
</configuration>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.38</version>
</dependency>

</dependencies>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>update</id>
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.5.1</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>update</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>rollback</id>
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.5.1</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>rollback</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>tag</id>
<build>
<plugins>
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.5.1</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>tag</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>

Liquibase Redshift loadUpdateData

$
0
0
Hi all,

I'm trying to create an AWS Redshift DB with data taken from a number of different CSV files.

I've tested the script locally using Postgres and all seems to be working well (produces the following types of output:
  1. DO
  2. $$
  3. BEGIN
  4. UPDATE public.example_db SET name = 'abc' WHERE other_name = '123';
  5. IF not found THEN
  6. INSERT INTO public. example_db (name, other_name) VALUES ('abc, '123');
  7. END IF;
  8. END;
  9. $$
  10. LANGUAGE plpgsql;
)

HOWEVER, when running this against a Redshift DB, it generates the standard insert:

  1. INSERT INTO public.example_db (name, other_name) VALUES ('abc', '123');
My changeset xml looks like this:

  1. <changeSet id="2.1" author="example" runOnChange="true">

  2.       <loadData file="/resources/002_resources/files/net_names.csv"
  3.                 schemaName="public"
  4.                 tableName="example_db">
  5.       </loadData>

  6.       <loadUpdateData file="/resources/002_resources/files/others.csv"
  7.                 schemaName="public"
  8.                 primaryKey="name"
  9.                 tableName="example_db">
  10.       </loadUpdateData>

  11.       <loadUpdateData file="/resources/002_resources/files/more.csv"
  12.                 schemaName="public"
  13.                 primaryKey="name"
  14.                 tableName="example_db">
  15.       </loadUpdateData>

  16.       <loadUpdateData file="/resources/002_resources/files/foo_bar.csv"
  17.                 schemaName="public"
  18.                 primaryKey="name"
  19.                 tableName="example_db">
  20.       </loadUpdateData>

  21.       <sqlFile path="../resources/002_resources/fill_in_nulls.sql" relativeToChangelogFile="true" />

  22.       <rollback>
  23.           <sqlFile path="../resources/002_resources/rollback.sql" relativeToChangelogFile="true" />
  24.       </rollback>

  25.   </changeSet>
Any ideas on what i can do to get this working? I run liquibase like:
  1. liquibase --defaultsFile=../../IdeaProjects/migrations/sandbox.properties updateSQL

With the defaults file containing the following information:

  1. url=jdbc:redshift://amazonURL.com:1234/dbName?ssl=true&sslfactory=com.amazon.redshift.ssl.NonValidatingFactory
    driver=com.amazon.redshift.jdbc41.Driver
    databaseClass=liquibase.ext.redshift.database.RedshiftDatabase
    username=123
    password=abc
    defaultSchemaName=public
    changeLogFile=changelog.xml
Any help would be greatly appreciated. If you need any extra information please let me know!

Re : Why does databasechangelog not have a primary key?

$
0
0
I've run into a problem because of the lack of a primary key on databasechangelog - on MySQL running with safe update mode the updates to that table fail. I don't know if it would be easy to make it database specific, but on MySQL I have to create my own primary key because Liquibase is unusable without one.

programatically call liquibase for data diff?

$
0
0
Hi, I have read a similar post, https://forum.liquibase.org/topic/is-it-possible-to-generatechangelog-difftypes-data-programatically, for generating data diff changelogs in java/junit code. I tried a similar way in my code with Liquibase 3.4.2 and set DiffTypes in code (code attached). However it did not work.

I am not sure if I set the DiffTypes correctly and wonder if this version of Library supports data diff or which version is capable of? Thanks.

- Diff DB
  1.                 String types = "tables,views,columns,indexes,foreignkeys,primarykeys,uniqueconstraints,data";

  2. CompareControl compareControl = new CompareControl(null, types);
  3. DiffResult diffResult = DiffGeneratorFactory.getInstance().compare(database, null, compareControl);
  4. ByteArrayOutputStream output = new ByteArrayOutputStream();

  5. new DiffToChangeLog(diffResult, new DiffOutputControl(false, true, true)).print(new PrintStream(output));
- Diff Snapshot
  1. DatabaseSnapshot originalSnapshot = SnapshotGeneratorFactory.getInstance().createSnapshot(database.getDefaultSchema(), database, new SnapshotControl(database, types));
  2. Liquibase liquibase = new Liquibase("db/changelog/db.changelog-newdata.xml", new ClassLoaderResourceAccessor(), database);
  3. // update DB data
  4.         liquibase.update("");
  5.         DatabaseSnapshot migratedSnapshot = SnapshotGeneratorFactory.getInstance().createSnapshot(database.getDefaultSchema(), database, new SnapshotControl(database, types));
  6.         DiffResult finalDiffResult = DiffGeneratorFactory.getInstance().compare(originalSnapshot, migratedSnapshot, compareControl);
  7.          new DiffToChangeLog(finalDiffResult, new DiffOutputControl(false, true, true)).print(new PrintStream(output));



Re : programatically call liquibase for data diff?

$
0
0
When you say it "did not work", could you be more specific? What did you expect to happen? What actually happened? Was there an error message? 

Also, that link does not work - when I click it I get a '404 not found' page.

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

Re : programatically call liquibase for data diff?

$
0
0
Thanks. I tried including "data" in Difftypes parameter and inserting data in DB, then run my diff code against a null DB. However, I could see diffs of schema but no content diffs. 

This happened by comparing both DBs and snapshots.

Regards


Re : programatically call liquibase for data diff?

$
0
0
It appears that you may need to call the method DiffOuitputControl.setDataDir() to get the data in the output. 

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

Re : Liquibase 3.4.2 H2 database

$
0
0
Hello 

Any update on this ?. This is actually blocking us move ahead with newer version of Liquibase.

Request your help here.

Regards
Vinitha

Liquibase Attempting to Run Twice

$
0
0
I ran all my liquibase changessets and the db (Oracle) was created successfully. over the period of several days, I ran update several times and it ran successfully. This morning when I the CI build ran, I noticed that the liquibase update task is failing because it is trying to rerun changesets that ran before. All entries in the DATABASECHANGELOG are marked as "EXECUTED". I didn't change the changesets at all. Any thoughts?

Re : Liquibase Attempting to Run Twice

$
0
0
An update about this: I figured out what the issue was. The GOCD pipeline that was kicking off that process was renamed which resulted in a renaming of the file path so liquibase attempted running those changesets again. The scripts should have been using relative path instead of full path. Thanks

Documentation bug for createSequence

$
0
0
The manual claims that the attribute ordered is supported for "informix, hsqldb, postgresql, oracle, firebird, h2"

http://www.liquibase.org/documentation/changes/create_sequence.html

However this is wrong for Postgres.

Postgres does not support the "ordered" attribute and when trying to run a changeSet that uses it, you get:

  1. INFO 7/29/16 11:58 AM: liquibase: Successfully released change log lock
  2. Unexpected error running Liquibase: Validation Failed:
  3.      1 changes have validation failures
  4.           ordered is not allowed on postgresql, test.xml::1::hans




One changelog file works for MSSQL to PostgreSQL migration but not MSSQL to MSSQL?

$
0
0
I've seen this similar topic before, but without a resolution.  A somewhat useful workaround, but not practical.


The problem is a validation error that ONLY happens using "migrate" on MSSQL.  The same file can be used to create a schema in postgres.  Why does it have a problem with MSSQL?  The change log was generated from MSSQL, but can't be used to migrate the schema to a different database on the same host.

  1. java -jar liquibase.jar --logLevel=info --changeLogFile=mssql-confluencetest-changelog.xml migrate
    
  2. INFO 7/27/16 6:14 PM: liquibase: Successfully acquired change log lock
    SEVERE 7/27/16 6:14 PM: liquibase: cvc-complex-type.2.3: Element 'createTable' cannot have character [children], because the type's content type is element-only.
    INFO 7/27/16 6:14 PM: liquibase: Successfully released change log lock
    Unexpected error running Liquibase: cvc-complex-type.2.3: Element 'createTable' cannot have character [children], because the type's content type is element-only.
    
    SEVERE 7/27/16 6:14 PM: liquibase: cvc-complex-type.2.3: Element 'createTable' cannot have character [children], because the type's content type is element-only.
    liquibase.exception.ChangeLogParseException: Error parsing line 144 column 23 of mssql-confluencetest-changelog.xml: cvc-complex-type.2.3: Element 'createTable' cannot have character [children], because the type's content type is element-only.
    	at liquibase.parser.core.xml.XMLChangeLogSAXParser.parseToNode(XMLChangeLogSAXParser.java:114)
    	at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:17)
    	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:1126)
    	at liquibase.integration.commandline.Main.run(Main.java:184)
    	at liquibase.integration.commandline.Main.main(Main.java:103)
    Caused by: org.xml.sax.SAXParseException; lineNumber: 144; columnNumber: 23; cvc-complex-type.2.3: Element 'createTable' cannot have character [children], because the type's content type is element-only.
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
    	at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(ErrorHandlerWrapper.java:134)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:437)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
    	at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:325)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator$XSIErrorReporter.reportError(XMLSchemaValidator.java:458)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.reportSchemaError(XMLSchemaValidator.java:3237)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.elementLocallyValidComplexType(XMLSchemaValidator.java:3200)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.elementLocallyValidType(XMLSchemaValidator.java:3160)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.processElementContent(XMLSchemaValidator.java:3062)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleEndElement(XMLSchemaValidator.java:2140)
    	at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.endElement(XMLSchemaValidator.java:859)
    	at com.sun.org.apache.xerces.internal.impl.XML11NSDocumentScannerImpl.scanEndElement(XML11NSDocumentScannerImpl.java:814)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2973)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
    	at com.sun.org.apache.xerces.internal.impl.XML11NSDocumentScannerImpl.next(XML11NSDocumentScannerImpl.java:857)
    	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
    	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
    	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
    	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
    	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:648)
    	at liquibase.parser.core.xml.XMLChangeLogSAXParser.parseToNode(XMLChangeLogSAXParser.java:106)
    	... 7 more
In this screenshot which shows the "hidden" characters....the change set for table AO_5FB9D7_AOHIP_CHAT_LINK is bad and the change set for table AO_5FB9D7_AOHIP_CHAT_USER is good.  And again, this same file works for PostgreSQL. 

Someone please help me out here!!


Pull request - CORE-2817 - constraintName attribute is missing from generated changelog for Sybase ASE 15.7

sqlfile tag in formatted Sql file

$
0
0
Hi,
I have got a formatted Sql file with all the CREATE and ALTER table statements.
But some statements are in an external file. What is the syntax for  sqlFile tag in Liquibase formatted sql file?

Thanks,
Nagma.

Re : sqlfile tag in formatted Sql file

$
0
0
There isn't really an equivalent - you would have to use database specific techniques. I searched for "Use One SQL file from another" and found some results. For example, if you are using MSSQL, you could do this:


If using Oracle, here are some ideas:

Because Liquibase executes SQL using JDBC calls rather than native tools (i.e. sqlcmd or sqlplus) you may run into difficulties with either of these techniques. 

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

json schema

$
0
0
Hello everyone.

Where can I find the json schema to liquibase json format?

My intention is to use it in visual studio code.

I'm planning to create the json schema to liquibase, but before create it I would like to know if someone have already did it.

Regards
Viewing all 1169 articles
Browse latest View live


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