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

DB2 stored procedures with liquibase : mixing 2 delimiters in generated SQL

$
0
0
Hello everybody,

i'm quite new to liquibase so i wish your kindness.

I try using <sqlFile> changelog wto create stored procedures.

My problem is relating to delimiters.

The sql code of my SP uses ; as delimiter so to create the SP i use @ delimiter
<sqlFile path="MY_SP.sql"
            encoding="ISO-8859-1" endDelimiter="@" splitStatements="false" />

I need to generate SQL to send to DBadmins but it mixes
MY_SP.sql (with @ delimiter)

and

INSERT INTO DATABASECHANGELOG ... (with ; delimiter)

DROP PROCEDURE MY_SP()@

CREATE OR REPLACE PROCEDURE MY_SP()
...@
INSERT INTO ACATLS.DATABASECHANGELOG ... ;

The resulting SQL code is wrong because there is no alternate delimiter feature in DB2 (like in Oracle)

My question is :
is there a way to define another delimiter when liquibase generate the INSERT INTO DATABASECHANGELOG statements ?

Many thanks in advance

Problem with the loadUpdateData with Oracle

$
0
0
Hi Guys,

I am using loadUpdateData to import CSV file data, it is working fine with MySQL, but with oracle I am having an issue. 

DECLARE
v_reccount NUMBER := 0;
BEGIN
SELECT COUNT(*) INTO v_reccount FROM translations WHERE context_pk = 'event.index' AND id_pk is NULL AND language_pk is NULL;
IF v_reccount = 0 THEN
INSERT INTO translations (context_pk, id_pk, language_pk, text) VALUES ('event.index', '1258', 'en', 'test');
ELSIF v_reccount = 1 THEN
UPDATE translations SET id_pk = '1258', language_pk = 'en', text = 'test' WHERE context_pk = 'event.index' AND id_pk is NULL AND language_pk is NULL;
END IF;
END;

Instead of pulling id_pk value from CSV, it is directly comparing to NULL and trying to execute the INSERT query all the time. Then Oracle is throwing "unique constraint (%s.%s) violated" error.

My CSV file data is

context_pk,id_pk,language_pk,text
event.index,1258,en,test

Please help me out from this.

Thanks,
Vijay

Cannot execute commands against an offline database when I am trying to connect Oracle offline

$
0
0
Below are the code which I am using: 
        
      private static String file="create-table.yml";
public static void main(String[] args) throws Exception {
Database database =createOfflineDatabase("offline:oracle");
Liquibase liquibase = new Liquibase(file, new ClassLoaderResourceAccessor(), database);
liquibase.update("test");
liquibase.dropAll();
}
private static Database createOfflineDatabase(String url) throws Exception {
              DatabaseConnection databaseConnection = new OfflineConnection(url, new ClassLoaderResourceAccessor());
              return DatabaseFactory.getInstance().openDatabase(url, null, null, null, null);
        }

Getting this exception :

Exception in thread "main" liquibase.exception.MigrationFailedException: Migration failed for change set create-table.yml::create-table.yml::vishwakarma:
     Reason: liquibase.exception.DatabaseException: Cannot execute commands against an offline database
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:619)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:79)
at liquibase.Liquibase.update(Liquibase.java:214)
at liquibase.Liquibase.update(Liquibase.java:192)
at liquibase.Liquibase.update(Liquibase.java:188)
at liquibase.Liquibase.update(Liquibase.java:181)
at com.test.liquibase.LiquibaseTest.main(LiquibaseTest.java:27)

Can you guys please help me if I missing something? 

Thanks in Advance.

Validation for rollback with ChangeSetId is not correct

$
0
0

Hello everybody,

Example:

  1. <changeSet id="id1" author="mmr" dbms="postgresql">

    <createTable tableName="TABLE_TO_DROP">
    <column name="ID" type="BIGINT"/>
    <column name="TEXT_VALUE" type="VARCHAR(64)"/>
    </createTable>

    <rollback>
    <dropTable tableName="TABLE_TO_DROP"/>
    </rollback>
    </changeSet>

    <changeSet id="id2" author="mmr" dbms="postgresql">

    <dropTable tableName="TABLE_TO_DROP"/>

    <rollback changeSetId="id1" changeSetAuthor="mmr"/>
    </changeSet>

This code runs correct when the underlying database is postgres.

Running the code on H2 database, i get this error:

  1. Caused by: liquibase.parser.core.ParsedNodeException: Change set path-ignored::id1::mmr does not exist
     at liquibase.changelog.ChangeSet.handleRollbackNode(ChangeSet.java:399)
     at liquibase.changelog.ChangeSet.handleChildNode(ChangeSet.java:317)
     at liquibase.changelog.ChangeSet.load(ChangeSet.java:311)
     at liquibase.changelog.DatabaseChangeLog.createChangeSet(DatabaseChangeLog.java:513)
     at liquibase.changelog.DatabaseChangeLog.handleChildNode(DatabaseChangeLog.java:311)
     at liquibase.changelog.DatabaseChangeLog.load(DatabaseChangeLog.java:282)
     at liquibase.parser.core.xml.AbstractChangeLogParser.parse(AbstractChangeLogParser.java:25)

It seems, that the liquibase validates the <rollback>-tag although the parent changeSet and the changeSet "id1" are both not for the H2 database.

My Question:

Is this a known bug? Do you know a work-around for this problem?

Thanks in advance and best regards,

Matthias

Liquibase Change set appears to be empty when executing update command

$
0
0

Before I explain my issue, I must declare that I'm a novice in Liquibase.

I'm trying to run liquibase update method in my Test class. My code reads the changeset file, acquires lock, reads from changelog and releases lock, but does not execute the changeset itself. Here's my structure:

Test class:

  1. public class LiquibaseTestDbUtil {

  2.     private static final String LIQUIBASE_CHANGELOG_FILE = "liquibase/liquibase-changelog-test.xml";
  3.     private static final String UNIT_NAME = "com.ihsinformatics.tbreach.api.test";
  4.     // Get entity manager
  5.     EntityManager entityManager = Persistence.createEntityManagerFactory(
  6.             UNIT_NAME).createEntityManager();

  7.     @Before
  8.     public void setupDatabase() throws Exception {
  9.         Connection connection = ((SessionFactoryImpl) entityManager.unwrap(
  10.                 Session.class).getSessionFactory()).getConnectionProvider()
  11.                 .getConnection();
  12.         Database database = DatabaseFactory.getInstance()
  13.                 .findCorrectDatabaseImplementation(
  14.                         new JdbcConnection(connection));
  15.         // Get liquibase instance / execute update / drop
  16.         URL file = ClassLoaderUtil.getResource(LIQUIBASE_CHANGELOG_FILE,
  17.                 LiquibaseTestDbUtil.class);
  18.         DatabaseChangeLog dbChangeLog = new DatabaseChangeLog(file.getPath());
  19.         Liquibase liquibase = new Liquibase(dbChangeLog,
  20.                 new ClassLoaderResourceAccessor(), database);
  21.         liquibase.update(new Contexts("test"));
  22.         // liquibase.dropAll();
  23.     }

  24.     @Test
  25.     public void someTestCase() throws Exception {
  26.     }
  27. }

Change log file:

  1. <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2.     xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">

  3.     <property name="schemaName" value="tbreach_api_test" dbms="mysql,oracle,postgresql" />

  4.     <changeSet author="owais.hussain" context="test" id="20180216-1" runOnChange="true">
  5.         <createTable tableName="data_log" schemaName="${schemaName}">
  6.             <column autoIncrement="true" name="log_id" type="INT">
  7.                 <constraints primaryKey="true" />
  8.             </column>
  9.             <column name="log_type" type="CHAR(6)">
  10.                 <constraints nullable="false" />
  11.             </column>
  12.             <column name="entity_name" type="VARCHAR(45)">
  13.                 <constraints nullable="false" />
  14.             </column>
  15.             <column name="record" type="TEXT" />
  16.             <column name="description" type="TEXT" />
  17.             <column name="date_created" type="datetime(6)">
  18.                 <constraints nullable="false" />
  19.             </column>
  20.             <column name="created_by" type="INT" />
  21.             <column name="created_at" type="INT" />
  22.             <column name="uuid" type="CHAR(38)">
  23.                 <constraints nullable="false" unique="true" />
  24.             </column>
  25.         </createTable>
  26.     </changeSet>

  27.     <!-- Test Data -->
  28.     <changeSet author="owais.hussain" id="2018-02-19" runOnChange="true">
  29.         <sqlFile dbms="mysql" path="src/test/resources/test-data.sql" />
  30.     </changeSet>

  31. </databaseChangeLog>

My persistence.xml file is kept in src/test/resources/META-INF/ directory with the following details:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3.     xsi:schemaLocation="
  4.         http://java.sun.com/xml/ns/persistence
  5.         http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">

  6.     <persistence-unit name="com.ihsinformatics.tbreach.api.test" transaction-type="RESOURCE_LOCAL">
  7.         <description>
  8.             Persistence unit for the JPA tutorial of the Hibernate Getting Started Guide
  9.         </description>
  10.         <provider>org.hibernate.ejb.HibernatePersistence</provider>

  11.         <properties>
  12.             <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.Driver" />
  13.             <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/tbreach_api_test" />
  14.             <property name="javax.persistence.jdbc.user" value="root" />
  15.             <property name="javax.persistence.jdbc.password" value="mypassword" />
  16.             <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
  17.             <property name="hibernate.show_sql" value="true" />
  18.             <property name="hibernate.hbm2ddl.auto" value="update" />
  19.         </properties>

  20.     </persistence-unit>

  21. </persistence>

I have the following dependencies in my pom.xml

  • junit 4.10
  • liquibase-core 3.5.4
  • mysql-connector-java 5.1.45
  • Other dependencies like log4j
When I execute the LiquibaseTestDbUtil as Junit in Eclipse, I get the following log:
  1. log4j:WARN No appenders could be found for logger (org.jboss.logging).
  2. log4j:WARN Please initialize the log4j system properly.
  3. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
  4. SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
  5. SLF4J: Defaulting to no-operation (NOP) logger implementation
  6. SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
  7. INFO 2/19/18 2:40 PM: liquibase: Successfully acquired change log lock
  8. INFO 2/19/18 2:40 PM: liquibase: Reading from tbreach_api_test.DATABASECHANGELOG
  9. INFO 2/19/18 2:40 PM: liquibase: Successfully released change log lock
But my Database (tbreach_api_test) looks empty, with only 2 liquibase tables, in which the databasechangelog is empty.

I dived into Debug mode to see that the changeLog object in Liquibase class is initialized, but is empty.

What am I missing?

MySQL types don't match when generating diff logs

$
0
0
Consider the following example of modifying an existing table -- change the column type from VARCHAR(256) to TEXT:

  1. ALTER TABLE Team
    CHANGE COLUMN Name Name TEXT NULL DEFAULT NULL ;
When I run create diff change log using diffChangeLog parameter, I get the following changeset:

      <changeSet author="dulino (generated)" id="1519671364901-3">

        <modifyDataType columnName="Name" newDataType="clob" tableName="Team"/>

        <dropNotNullConstraint columnDataType="clob" columnName="Context_Country_Code" tableName="Team"/>

    </changeSet>


Note the column data type becomes "clob", not "text." We are using MySQL. This does not happen for a brand new table, only for existing tables.


Why is that? Is there something I am doing wrong or is it a bug?


Why is that?

createProcedure attributes error

$
0
0
Hi all,
I'm a Liquibase newbie and am experimenting with using Liquibase with Oracle.
I'm trying to use the createProcedure tag to create a PL/SQL procedure. I referenced the example from the documentation. However, the attributes for that tag cause errors:
Changelog XML:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" 
  3.     xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" 
  4.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  5.     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">
  6.    <changeSet author="liquibase-docs" id="001">
  7.       <createProcedure
  8.         comments="creating procedure test" >
  9.         create or replace procedure test
  10.         is
  11.         begin
  12.             null;
  13.         end;
  14.       </createProcedure>
  15.    </changeSet>
  16. </databaseChangeLog>


$ ./liquibase update
Unexpected error running Liquibase: Error parsing line 8 column 45 of ../src/plsql/prc.xml: cvc-complex-type.3.2.2: Attribute 'comments' is not allowed to appear in element 'createProcedure'.

This happens to any attribute I add to the tag.

Am I doing something wrong?

Thanks!
Christoph



Re : Configurable DATABASECHANGELOG table name ?

$
0
0
Can we please request a new feature to be able to configure not only via system settings.  2 disadvantages exist here:
1. It forces ITO to change a standard deployment workflow. Which is not good when there are a lot of clients. The solution must exist when we build our application. 
2. When different applications are deployed and they share the same database, I would say it is impossible to control it via system setting. I cannot change it, deploy one application, change the settings again, deploy the next application.

I would offer to include this feature into the master changelog. It is the only file. It will be clear and quite flexible, I think. Probably settings should have higher priority, or, I would even throw an exception if it is configured both, via setting and via the master changelog. User must fix it first. We must be as explicit here as possible.

liquibase extensions not being recognised

$
0
0
I'm trying to write a small extension, the ultimate intention being to override some behaviour when using MySQL to better suit my application's use case. This is what I've tried so far:

I've written a noddy "hello world" level database extension, at present all this does is extend the standard MySQL database implimentation with priority of Default + 1 and some extra logging to prove that I've successfully overridden the default implimentation. To guard against the possibilty that the extension is working and the logging isn't, it also overrides executeStatements with a no-op, so I should see no changes in my MySQL database if my implimentation is being used.

Unfortunately, it's not working. Liquibase returns happily and all changes are executed as normal, so it must still be using the standard Database implimentation.

I wrote the extension in groovy and packaged it up in a jar using gradle. I've placed the jar in the liquibase_home/lib folder (which is deffinitely on the classpath because thats where the MySQL connector jar is).

The code is currently in package liquibase.ext.database, although I've also tried liquibase.ext and liquibase.database.ext, both with and without a sub package wrapping my code, all with the same result.

I've tried this with both the current binary distribution v3.55, and a home compiled version from the master branch v3.60.

I tried running the source code in debug mode from intellij and the classloader lists my extension jar under classFilesByLocation but does not recognise my class in classesByPackage.

I'm running MacOS Siera if that makes any difference.

I've also tried downloading an extension from the Liquibase Extensions page, and I can't get that to load either.

Any suggestions anyone may have as to what I'm doing wrong would be gratefully received, I'm about ready to throw in the towel.

Liquibase version upgrade changes datatypes and breaks backward compatibility

$
0
0
Hi all,

I recently upgraded my liquibase version from 3.3.5 to 3.5.5 and ran into some compatibility problems as some liquibase default datatypes are now resolved to other dbms specific datatypes. I need to maintain compatibility with different flavours of mssql, mysql, oracle and postgres and have 3 years worth of xml change sets that cannot be modified as this would break the backwards compatibility of my application with previous application releases.

On postgres, for example, liquibase now  resolves blob to oid and before it was resolved to bytea. I will most likely discover other liquibase standard datatype mappings that have changed.
As a workaround for this problem I tried altering the columns types that have changed, through liquibase change sets, back to bytea on prostges and got casting errors as postgres cannot cast oid to bytea.

Is there any way in which I can configure liquibase to use the data type mappings from 3.3.5 instead of 3.5.5?
If not is there any workaround I can use in order to maintain the backward compatibility my change sets? 

Re : 2 classpath questions

$
0
0
Hi Steve,

I am getting the same error while using liquibase on linux server.
Error is as follow. Can  you please help us with the solution to fix the issue

Details are as follow:

Source Directory: /appl/pwrmartd/liquibase-3.1.1-bin
Properties file

#Teradata
driver=com.teradata.jdbc.TeraDriver
classpath:/appl/pwrmartd/liquibase-3.1.1-bin/lib/tdgssconfig.jar;/appl/pwrmartd/liquibase-3.1.1-bin/lib/terajdbc4.jar;/appl/pwrmartd/liquibase-3.1.1-bin/lib/liquibase.jar
url=jdbc:teradata://<server name>/database=<databasename>
username=username
password=*****
changeLogFile=/appl/pwrmartd/liquibase-3.1.1-bin/TERAChangeLogMasterCurrent.xml


Command execution:
liquibase --defaultsFile=/appl/pwrmartd/liquibase-3.1.1-bin/liquibase.properties --defaultSchemaName=<databasename> --changeLogFile=/appl/pwrmartd/liquibase-3.1.1-bin/changeLogFile/teradata/TERAChangeLogMasterCurrent.xml --logLevel=DEBUG --logFile=/appl/pwrmartd/liquibase-3.1.1-bin/logs/log.txt update


Error Encountered: 

  Unexpected error running Liquibase: /appl/pwrmartd/liquibase-3.1.1-bin/lib/tdgssconfig.jar;/appl/pwrmartd/liquibase-3.1.1-bin/lib/terajdbc4.jar;/appl/pwrmartd/liquibase-3.1.1-bin/lib/liquibase.jar does not exist

SEVERE 3/5/18 5:09 PM: liquibase: /appl/pwrmartd/liquibase-3.1.1-bin/lib/tdgssconfig.jar;/appl/pwrmartd/liquibase-3.1.1-bin/lib/terajdbc4.jar;/appl/pwrmartd/liquibase-3.1.1-bin/lib/liquibase.jar does not exist
liquibase.exception.CommandLineParsingException: /appl/pwrmartd/liquibase-3.1.1-bin/lib/tdgssconfig.jar;/appl/pwrmartd/liquibase-3.1.1-bin/lib/terajdbc4.jar;/appl/pwrmartd/liquibase-3.1.1-bin/lib/liquibase.jar does not exist
at liquibase.integration.commandline.Main.configureClassLoader(Main.java:828)
at liquibase.integration.commandline.Main.run(Main.java:187)
at liquibase.integration.commandline.Main.main(Main.java:103)

Re : How can I set the Sender's address in Jenkins?

$
0
0
Jenkins uses the System Admin e-mail address as the sender address for e-mail notification. You can configure this under Manage Jenkins -> Configure System. This is under the Jenkins Location header on that page! It is not immediately obvious that this setting is tied to the e-mail notification settings since it is not under the E-mail notification header on the configuration page.

jenkins interview questions and answers

Re : Release Updates

$
0
0
Hi Nathan,
thanks for these updates on the future of Liquibase.
As I have seen you did provide a 3.5.4 and 3.5.5 bug fix release in February this year. It is really great to see some release activity coming back to this project. I am also really looking forward to the upcoming 3.6 release. As I understand the 3.6 release may include many of the "Manul fork" merge requests.
Is there anything a regular user can do right now to help with the work that has to be done to get the 3.6 release to GA (general availability)?

Thanks for your work and your updates on this,
Tobias

Re : 2 classpath questions

$
0
0
Kishlay, it appears that you are using semicolons in your classpath rather than colons. semicolons are valid on Windows, but colons should be used on Linux. 

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

Re : liquibase extensions not being recognised

$
0
0
It all seems like it should be working for you. The fact that it is MacOS shouldn't matter

Liquibase looks for extensions by the packages listed in Liquibase-Package fields of MANIFEST.MF files. The standard liquibase jar ships with "liquibase.ext" as a package as well as "liquibase.database" and so either of your packages should have worked.

The current DefaultPackageScanClassResolver looks for files ending with .class to find classes. Is your extension packaged with  ".groovy" extensions?

Nathan



Re : Release Updates

$
0
0
Yes, did get the 3.5.5 release out. The 3.6.0 release will have all the Manul fork pull requests as well as a bunch of other things as well.

I've incorporated all the pull requests and bugfixes I'm planning for 3.6.0 and am currently doing some final testing of it. If you would have a chance to do a bit of testing with it, that would be a big help.

Re-configuring a build server will be a post-3.6.0 release, but I will put a pre-release build at https://github.com/liquibase/liquibase/releases/ for anyone that would like to test it out.

Thanks,
Nathan

Re : createProcedure attributes error

$
0
0
It looks like your XSD is referencing version 3.0. It should be 3.5. I'll take a look at the documentation

Thanks,
Nathan

Re : createProcedure attributes error

$
0
0
Thanks Nathan. I changed the XSD to 3.5, but got the same error.

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" 
  3.     xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" 
  4.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  5.     xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.5.xsd         http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
  6.    <changeSet author="liquibase-docs" id="001">
  7.       <createProcedure
  8.         comments="creating procedure test" >
  9.         create or replace procedure test
  10.         is
  11.         begin
  12.             null;
  13.         end;
  14.       </createProcedure>
  15.    </changeSet>
  16. </databaseChangeLog>

Re : createProcedure attributes error

$
0
0
Looking at the XSD, it looks like it needs to be a nested <comment> tag. Like:

  1.  <changeSet author="liquibase-docs" id="001">
  2.       <createProcedure>
  3.         <comment>creating procedure test</comment>
  4.         create or replace procedure test
  5.         is
  6.         begin
  7.             null;
  8.         end;
  9.       </createProcedure>
  10.    </changeSet>

Re : createProcedure attributes error

$
0
0
I tried your suggestion. The procedure got created, but the entry in DATABASECHANGELOG did not show the comment. Also, the rollback failed. Shouldn't the createProcedure automatically suggest the drop command on rollback?

  1. ~/dev/liquibase$ ./liquibase rollbackCount 1
  2. Unexpected error running Liquibase: No inverse to liquibase.change.core.CreateProcedureChange created


Thanks,
C
Viewing all 1169 articles
Browse latest View live


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