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

Re : How to Create Procedure on HANA database through Liquibase

$
0
0
Passing sql files into the xml just works fine, we will take it as resolution for now. 

<changeSet author="DBTest-AllProc" id="1491933527660-9999">
<sqlFile path="D:\xml\HANA\proc\proc_test.sql" splitStatements="false"/>
</changeSet>

Running Liquibase code 3.5.3 is slow

$
0
0
Hi,

I have the set of Liquibase scripts which recently got migrated from 2.0.1 to 3.5.3.  Scripts which were running in 25 mins in 2.0.1 is taking about 1 hr 55 mins to execute in 3.5.3.  We cannot afford this increase in time.

Any help is highly appreciated?

Thanks
Manohar

Oracle extensions - create synonym

$
0
0
Hi all,
         I'm using the Oracle extension to create a synonym. I'm using this XML as a test:

      <changeSet id="9" author="miami.user" failOnError="true">
<ora:createSynonym objectName="miami.REPORT"
synonymName="miami.REPORT_SYN" replace="true" />
</changeSet>

But the synonym is not being created. All other changesets are being executed and performing as expected. Can anyone help me please?

Regards

Angus

Unable to replace logger, ServiceLocator.instance() returns null

$
0
0
Java SDK 1.8.0_131
Liquibase 3.5.3
eclipse IDE Neon 3 (eclipse 4.6.3)

I am trying to replace the logger as outlined in Fixing liquibase logging (in Spring) with SLF4J and Log4J but so far I haven't been successful.  

The reason seems to be because ServiceLocator.instance(), called from LogFactory.getLog(), returns a null, and the defaultLogger is returned instead.

Is there some obvious initialization code that may I have missed? (I have used examples found by googling, combined with trial and error).

I first tried replacing the logger by adding a maven dependency to Matt Bertolinis liquibase-slf4j, but that didn't have any effect.

I then tried replacing the logger as simply as possible:
  1. Created a package liquibase.ext.logging in the project where I'm calling Liquibase from
  2. Created a class "public class UkelonnLiquibaseLogger extends AbstractLogger" in this package
The UkelonnLiquibaseLogger class at this time, just had empty methods.  I figured that if all of the Liquibase output went away, the class would have been found, and that I would see this as soon as I started running unit tests.

But the liquibase output continued to be written to the console, so the class wasn't picked up.

When I debugged into the startup code I was able to hit code in the ServiceLocator constructor, called from the static initializer of the ServiceLocator class. Eclipse didn't let me set any breakpoints inside the static initializer of ServiceLocator so I wasn't able to see what was going on there. I wasn't able to figure out if any exceptions were thrown from the constructor either.

However when I next hit the breakpoints in ServiceLocator.getInstance() the instance was null.

I had a breakpoint in ServiceLocator.setInstance() as well, but this breakpoint was never called.

This is how I create and use Liquibase:
  1.     public void createSchema(PooledConnection connect) throws SQLException, LiquibaseException {
  2.         DatabaseConnection databaseConnection = new JdbcConnection(connect.getConnection());
  3.         ClassLoaderResourceAccessor classLoaderResourceAccessor = new ClassLoaderResourceAccessor(getClass().getClassLoader());
  4.         Liquibase liquibase = new Liquibase("db-changelog/db-changelog.xml", classLoaderResourceAccessor, databaseConnection);
  5.         liquibase.update("");
  6.     }
Thanks!

- Steinar

Re : Unable to replace logger, ServiceLocator.instance() returns null

$
0
0
Now I've succeeded in having the custom logger picked up when running in the unit tests.

What I did to fix this, was to ensure that the getPriority() method of my logger returned a high number:
  1. package liquibase.ext.logging;

  2. import liquibase.logging.core.AbstractLogger;

  3. public class UkelonnLiquibaseLogger extends AbstractLogger {
  4.     ...
  5.     /**
  6.      * The value returned here will determine if liquibase is to use this logger.
  7.      * If the value is too low, liquibase will use the default logger.
  8.      */
  9.     @Override
  10.     public int getPriority() {
  11.         return Integer.MAX_VALUE;
  12.     }
  13. }
When debugging I found that the ServiceLocator.getInstance() method eventually returned something other than null, and a logger was attempted created. However, since the getPriority() method returned 0, the default logger was picked instead.

Now this works for me in the unit tests.

However, in the OSGi context liquibase still logs to the console. This happens both in the karaf-based pax exam tests, and in apache karaf itself.

I have exported the liquibase.ext.logger package from the OSGi bundle the UkelonnLiquibaseLogger is implemented in.

FYI The reason I picked ClassLoaderResourceAccessor over the OSGiResourceAccessor, was that I couldn't figure out how to make the OSGiResourceAccessor work in the unit tests, and the ClassLoaderResourceAccessor with the class loader set explicitly, finds the database changeset files both when running in unit tests and when running in OSGi.

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

$
0
0

I'm sending mail from Jenkins to an anonymous SMTP relay internally. That relay then securely sends mail to exchange online via TLS on port 587. The transport works perfectly, the issue is that Microsoft requires the Sender address match the authentication credentials login name which is the same as the account email address. For example sake, say this is foo@mycompany.com. How can I make jenkins always send mail from foo@mycompany.com?

BTW when I say the transport works perfectly what I mean specifically is that I can drop a formatted e-mail file into the "Pickup" directory on the SMTP relay server and it is properly sent to any recipient provided the From address is foo@mycompany.com.

Re : Unable to replace logger, ServiceLocator.instance() returns null

$
0
0
Now I have liquibase logging to the karaf log instead of flooding the karaf console.
It wasn't easy, but I got help: see this message on the karaf user mailing list

In short, what's needed, is:
  1. A maven module that rebundles the liquibase-slf4j maven dependency into an OSGi bundle fragment that is connected to the org.liquibase.core OSGi bundle (ie. the liquibase-core maven dependency)
  2. A karaf feature that loads the rebundled liquibase-slf4j  OSGi fragment before it loads liquibase-core
This puts the liquibase.ext.logger.slf4j package into a place where the bundle classloader can find it.

Note. The classloader will not find the liquibase.ext.logger.slf4j package if it is made available as a package exported by an OSGi bundle. It has to be "included" into the org.liquibase.core bundle.

Re : Unable to replace logger, ServiceLocator.instance() returns null


sqlFile in sqlCheck

$
0
0
Hi,
I am using Liquibase (aml) and would like to include the <sqlFile> in <sqlCheck> in <preCondition>.

I would like to do something like this:

  1. <preConditions onFail="HALT">
  2. <not>
  3. <indexExists indexName="ux_uuid" tableName="test_table"/>
  4. </not>
  5. <sqlCheck expectedResult="0">
  6. <sqlFile path="my/path/file.sql" relativeToChangelogFile="true"/>
  7. </sqlCheck>
  8. </preConditions>

Is this possible or are there any workarounds?

Thanks

Rollback without tag in changeset

$
0
0
We are using the git flow model for our development and trying to integrate liquibase for managing the database versioning efficiently. The problem comes when a developer is working on a feature branch and has made a DB script which is executed on his database and another developer's database, but it is not yet part of any release so it is not yet tagged. Now that feature is tested and becomes part of release and we tag the changeset and execute it on production.

The questions is how to rollback the changes made on the developer's machine because there was no tag defined at the moment when the script got executed and when we try to update it will the current tag it will show error "The table already exists".

How to manage these conditions through liquibase efficiently ?

Unexpected error running Liquibase: Column 'ID' cannot be null

$
0
0
I'm running docker mysql:5.6, and when I try to run liquibase against it i get this error

Unexpected error running Liquibase: Column 'ID' cannot be null

"runalways" changesets seem to break rollback functionality

$
0
0
Liquibase Version: 3.5.3
Database: PostgreSQL 9.3.15
OS: Windows 10

I am seeing strange behaviour when trying to utilise the "runalways" attribute on changesets. I am using liquibase in the following way (simplified example):

Master Changelog
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <databaseChangeLog
  3.         xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  4.         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5.         xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
  6.          http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">

  7.     <include file="updates.xml" relativeToChangelogFile="true"/>
  8.     <include file="always.xml" relativeToChangelogFile="true"/>
  9. </databaseChangeLog>

Updates Changelog:

  1. <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  2.                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3.                    xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
  4.                    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd
  5.         http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"
  6.                    logicalFilePath="updates.xml">
  7.     

  8. <changeSet id="updates-1" author="me">
  9. <sql>
  10. select 1;
  11. </sql>
  12. <rollback>
  13. select 1;
  14. </rollback>
  15.     </changeSet>
  16. <changeSet id="updates-2" author="me">
  17. <sql>
  18. select 1;
  19. </sql>
  20. <rollback>
  21. select 1;
  22. </rollback>
  23.     </changeSet>
  24. </databaseChangeLog>

Always Changelog:

  1. <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  2.                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3.                    xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
  4.                    xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd
  5.         http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd"
  6.                    logicalFilePath="always.xml">
  7. <changeSet id="always-1" author="me" runAlways="true">
  8. <sql>
  9. select 1;
  10. </sql>
  11. <rollback>
  12. select 1;
  13. </rollback>
  14.     </changeSet>
  15. </databaseChangeLog>
The "always" changelog is being used to perform a handful of maintenance operations on the DB like making sure certain indexes exist etc.

I run a liquibase update, and then tag the schema with the tag "build-1", and end up with what I would expect in the databasechangelog:



If I then add another changeset "updates-3" to the end of my "updates" changelog, and tag the schema as "build-2", I then receive the following:



I have now lost my tag of "build-1" that would have let me rollback changeset "updates-3" as the databasechangelog record that was tagged with "build-1" has been been "RERAN", and had it's dateexecuted value updated. When the tag of "build-2" was applied, it then updated the "always-1" databasechangelog record.

Is this a bug, or am I misunderstanding the way in which the tags work with liquibase?

Thanks.

Does liquibase support Invoking batch of sql from a single sql?

$
0
0
I am using liquibase to execute my sql scripts , my database is oracle. I would like to how to invoke multiple sqls .
My changeset looks like this
<changetset id = "abc" author = "system">
 <executeCommand  executable = C:\sqlplus.exe >
      <arg value = dbcredentials />
      <arg value = pathtosql/test.sql/>
  </executeCommand>
</changeset>

in test.sql file i have two more sql files which contains my actual sql scripts (two insert into table scripts)

insert1.sql
insert2.sql

what i am trying to do is , trying invoke couple of sql scripts from one test.sql.This is to know if it is possible to do or not?
When run liquibase went to hang state.
Note : I had used exit; / at the end of the actual scripts and the insert1.sql works perfect from liquibase when called directly.


Cannot find database driver: com.mysql.jdbc.Driver

$
0
0
Hi,
I'm trying to running liquibase on my windows machine, trying to connect to MySQL DB installed locally.
Here's is the command I run:

liquibase.bat --driver=com.mysql.jdbc.Driver --changeLogFile=changelogfile.xml --url="jdbc:mysql://localhost/alex_test_db" --username=ralex --password=SOME_PWD migrate

When I run this command, I'm getting the following error, saying that it can't locate the MySQL driver:

D:\temp\LiquiBase>liquibase.bat --driver=com.mysql.jdbc.Driver --changeLogFile=changelogfile.xml --url="jdbc:mysql://loc
alhost/alex_test_db" --username=ralex --password=SOME_PWD migrate
Unexpected error running Liquibase: java.lang.RuntimeException: Cannot find database driver: com.mysql.jdbc.Driver

I've installed MySql
on my machine at the following path:
C:\Program Files (x86)\MySQL\
- and the Connector/J is at the same path under Connector.J 5.1 sub-dir.

Any help will be much appreciated, as I'm new to liquibase and really not sure what should I do to make it work.

Many Thanks,
Alex

Liquibase Maven / Spring / Hibernate build integration

$
0
0
Hi,
First of all, thank you for the great work on liquibase!

I am starting to integrate liquibase in order to industrialize database schema migrations on Jspresso based applications (Maven/Spring/Hibernate). The objective is to be able to generate version to version migration scripts as much as possible and complete them with manual changes when needed. So far, I've come up with a working solution using a combination of the liquibase Maven plugin, liquibase-hibernate plugin and HSQL.

The process is the following :
  • store a file-based HSQL schema in the project versioned source tree (aka current). This schema should evolve by following the development progression.
  • use the generateChangeLog goal to generate the install changelog for a version based on the Hibernate model (fresh for every build). The install changelog is stored in the source tree per version.
  • apply it (update goal) to a fresh in-memory HSQL instance (aka reference).
  • use the diff goal to generate/update a diff changelog between the current and reference. This diff changelog is also stored in the source tree per version.
  • update the current using the diff changelog in order to align it with the reference and make it ready for next build diff change generation.

This way, I get a full install script per version and a migration script from version N-1 to version N. And everything is DB agnostic.

So far so good ;-)


I still have some questions pending :

1. I've hit a problem on the latest release 3.5.3 regarding re-creation of untouched foreign keys on Hibernate entities inheritance mapping (I think that it is linked to CORE-2928). 3.6.0-SNAPSHOT works fine. Is there a public maven repository for liquibase snapshot artifacts ? Any planned date for a 3.6.0 release ?

2. When generating the diff changelog, I couldn't find a way to force the author of the changesets like I can do it for the generateChangeLog goal using the changeSetAuthor configuration parameter. Am I missing something ?

3. A more general question regarding the Hibernate Dialect used for generating the changelogs from the Hibernate model (install and upgrade). What is the impact of the used dialect on the changelogs ? As I understand it, there shouldn't be any since there is no DB-specifics in the produced files, but correct me if I'm wrong.

4. I tried to force the dialect to org.hibernate.dialect.HSQLDialect during the build by using the dialect URL parameter (e.g. hibernate:spring:org/jspresso/hrsample/core-config.xml?bean=hibernateSessionFactory&dialect=org.hibernate.dialect.HSQLDialect) but AFAICT, it does not override the onde declared in the Spring configuration (wich might be the one of the targeted production database). It's not a big thing if (3.) is ok, but can be problematic if not. Again, am I missing something ?

Thank you for any advice and sorry for such a long post...
Vincent

Re : Does liquibase support Invoking batch of sql from a single sql?

$
0
0
You could call them using sqlfile tag inside changeset. They cant have sqlplus commands but for simple sql files it works very nicely.

command line > logFile option is not present

UpdateSql mode offline include create / insert statements for the DatabaseChangeLog?

$
0
0
The out-of-line output of UpdateSql will include create / insert statements for the DatabaseChangeLog table if it is executed with the parameters:

Liquibase --changeLogFile = / home / db / masterchangelog.xml --url: offline: oracle? ChangeLogFile = / home / databasechangelog.csv and outputLiquibaseSql = true --logLevel = information --updateSQL - Update.sql

But it sends an error:

Unexpected error while executing Liquibase: Unknown parameter: 'url: offline: oracle? ChangeLogFile "

Any ideas or help please

empty 'author' and 'id' attributes in change set

$
0
0
So it happened that I forgot to include both 'author' and 'id' attributes in a change set.

{
  "databaseChangeLog": [
    {    
      "changeSet": {
          "changes": [
        { "sql": "set session_authorization=pawel;
        ALTER TABLE ONLY table1 ALTER COLUMN id SET DEFAULT nextval('table1_id_seq'::regclass);
        SELECT setval('table1_id_seq', max(id) + 10) FROM table1;
        reset session authorization;
        "
        }
        ]
      }
    }
  ]
}


Liquibase error-ed out as expected with message:

Unexpected error running Liquibase: ERROR: null value in column "id" violates not-null constraint
  Detail: Failing row contains (null, null, liquibase/pawel/some_update..., 2017-06-26 20:04:05.067686, 2, EXECUTED, 7:b169dadba628d406299d40596bf63325, sql, , null, 3.5.3, null, null, 8521845043).


but it did alter the table.

So as I understand it the content of the "sql" and insert into 'databasechangelog' were not executed in the same transaction.

What am I doing wrong?
Did I misunderstand meaning of "runInTransaction" attribute?

Cheers

CustomSqlChange for one type of db was compiled for another ones too

$
0
0
In my liquibase project I created changeset for Oracle db (dbms = "oracle" in xml file) generated by CustomSqlChange java class. It could be successfully applied directly to my db. But in my main spring project I use SpringLiquibase for repository tests (DBUnit). Such tests use H2 db, and so on CI pipeline only my h2 liquibase changesets are applied.
The problem is that oracle changeset with customSqlChange falls down in CI due to
Caused by: liquibase.exception.CustomChangeException: java.lang.ClassNotFoundException:
  1. ....
  2. 11:33:20 [error]     at liquibase.change.custom.CustomChangeWrapper.setClass(CustomChangeWrapper.java:96)
  3. 11:33:20 [error]     at liquibase.change.custom.CustomChangeWrapper.load(CustomChangeWrapper.java:293)
  4. 11:33:20 [error]     ... 77 more
  5. 11:33:20 [error] Caused by: java.lang.ClassNotFoundException: com.myClassForCustomSqlChange
  6. 11:33:20 [error]     at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
  7. 11:33:20 [error]     at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
  8. 11:33:20 [error]     at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
  9. 11:33:20 [error]     at java.lang.Class.forName0(Native Method)
  10. 11:33:20 [error]     at java.lang.Class.forName(Class.java:348)
  11. 11:33:20 [error]     at liquibase.change.custom.CustomChangeWrapper.setClass(CustomChangeWrapper.java:87)
  12. 11:33:20 [error]     ... 78 more
  13. ....
So, even changeset is created for oracle, liquibase is trying to compile customSqlChange java file for H2. It is strange because it shouldn't be used by h2 db. So can you propose some effective solutions for this issue?

P.S. just a piece of code in my spring configuration for liquibase run:
  1. @Bean
    public SpringLiquibase springLiquibase(@Named(value = "dataSource") DataSource dataSource) {
    SpringLiquibase springLiquibase = new SpringLiquibase();
    springLiquibase.setDataSource(dataSource);
    springLiquibase.setChangeLog(DB_CHANGELOG_MASTER_FILE);
    springLiquibase.setIgnoreClasspathPrefix(true);
    springLiquibase.setResourceLoader(new PathMatchingResourcePatternResolver());
    return springLiquibase;
    }


Viewing all 1169 articles
Browse latest View live


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