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

Re : How to add JSONB columns for PostgreSQL?

$
0
0
Just use jsonb as the type:

  1. <column name="doc" type="jsonb"/>

Re : slash / after plsql block in sql script included by sqlFile tag

$
0
0
The following works fine for me:

* only put one procedure into one SQL file.
* end the procedure definition with a / on a single line.

Then use the <sqlFile> tag to run the script and define the proper endDelimiter:

  1.     <sqlFile path="create_proc.sql"
                 relativeToChangelogFile="true"
                 stripComments="false"
                 splitStatements="true" endDelimiter="\n/" />    

Note the definition of the endDelimiter: a new line followed by a forward slash.

If you do want to keep multiple PL/SQL CREATE statements in a single file, then use

  1. endDelimiter="\n/\n"

together with splitStatements="true". I think that works fine as well. But I haven't used that for ages.




includeAll not working for multimodule project with spring

$
0
0
As in title. If i place changelogs in module different than the one launched with application context includeAll is not working when i run application from jar file. Everything works fine if i run application normally (by maven command not jar file). Or put chagelogs in module with spring application context.


Module2 is starting module with application context, i'm using spring boot for running application. Module1 is child of module2 in other words module2 includes the first one. I'm using most recent version of liquibase core namely 3.4.2

Here is application context
  1. <bean id="liquibase" class="liquibase.integration.spring.SpringLiquibase">
    <property name="dataSource" ref="dataSource"/>
    <property name="changeLog" value="classpath:db-changelog.xml" />
    </bean>

And master changelog

Maybe I would explain it better by directory structure.

 Not working directory structure
      .
      ├── Module1
      │   ├── src
      │   │   └── main
      │   │       └── resources
      │   │           ├── db-changelog.xml
      │   │           └── sql
      │   │               ├── 001-test.sql
      │   │               └── 002-test.sql
      │   └── target
      │       ├── classes
      │       │   ├── db-changelog.xml
      │       │   └── sql
      │       │       ├── 001-test.sql
      │       │       └── 002-test.sql
      │       └── Module1-1.0-SNAPSHOT.jar
      |
      └─ Module2
         ├── src
         │   └── main
         │       └── resources
         │           ├── applicationContext.xml
         │           └── mybatis-config.xml
         └── target
             ├── classes
             │   ├── applicationContext.xml
             │   └── mybatis-config.xml
             └── Module2-1.0-SNAPSHOT.jar
   
INFO 30.11.15 01:05: liquibase: Successfully acquired change log lock
WARNING 30.11.15 01:05: liquibase: included file classpath:db-changelog.xml/ is not a recognized file type
Working
   
      .
      ├── Module1
      │   ├── src
      │   │   └── main
      │   │       └── resources
      │   └── target
      │       ├── classes
      │       │   ── oceniarka
│   └── Module1-1.0-SNAPSHOT.jar │ └── Module2    ├── src    │   └── main    │      └── resources    │      ├── applicationContext.xml    │      ├── db-changelog.xml    │      ├── mybatis-config.xml    │      └── sql    │      ├── 001-test.sql    │          └── 002-test.sql    └── target    ├── classes    │   ├── applicationContext.xml    │   ├── db-changelog.xml    │   ├── mybatis-config.xml    │   └── sql    │   ├── 001-test.sql    │   └── 002-test.sql    └── Module2-1.0-SNAPSHOT.jar
INFO 30.11.15 01:14: liquibase: Successfully acquired change log lock
WARNING 30.11.15 01:14: liquibase: included file classpath:db-changelog.xml/ is not a recognized file type
INFO 30.11.15 01:14: liquibase: Reading from oceniarka.DATABASECHANGELOG
INFO 30.11.15 01:14: liquibase: classpath:db-changelog.xml: sql/002-test.sql::raw::includeAll: Custom SQL executed
INFO 30.11.15 01:14: liquibase: classpath:db-changelog.xml: sql/002-test.sql::raw::includeAll: ChangeSet sql/003-test.sql::raw::includeAll ran successfully in 17ms

This happens for reading sql or xml files both. Problem exists only for running application from jar. I would classify this as a bug because spring properly recognize db-changelog.xml in other module, but master changelog cannot reference sql directory with "include all". I think this is happens because liquibase use some module relative variable for recognizing path.Referencing files from another module by including one-by-one ("include file" instead "includeAll") works fine. I would be very grateful for fixing the bug or some workaround. Also sorry for my english and formatting (it looks like i seriously messed up something in html  ).

Re : Liquibase unknown database error.

$
0
0
Several databases do things like that - automatically convert the case of all table names, etc. written to the database to either uppercase or lowercase, and then similarly convert queries to all uppercase or lowercase. But they typically also support a mode where you quote the names, which prevents the names from being converted, and can prevent queries from working as a human might expect. 

The basic rule with these kinds of databases is that if you use quotes when creating the table/column/etc., then you must also use quotes and the same case when querying. For example, if you created the database named "MyTestDB" with quotes and mixed case, then querying for mytestdb (all lower case) will not work. 

To provide the correct quoting behavior for Liquibase, you can use the  objectQuotingStrategy="QUOTE_ALL_OBJECTS" attribute on your changeSet attribute or on the databaseChangeLog root element to override the default logic of "only quote objects that have to be"

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

Re : Liquibase unknown database error.

$
0
0

 Several databases do things like that - automatically convert the case of all table names, etc. written to the database to either uppercase or lowercase
This is required by the SQL standard: unquoted identifiers have to be stored in uppercase and they have to be case-insensitive.


Unable to generate offline migration script for PostgreSQL database

$
0
0
Hi

I would like to use Liquibase to generate offline SQL migration scripts for one of my projects and have encountered an issue when creating scripts for PostgreSQL databases.

The entry in the plugins section of my POM file is as follows:
  1. <plugin>
  2.     <groupId>org.liquibase</groupId>
  3.     <artifactId>liquibase-maven-plugin</artifactId>
  4.     <version>3.4.2</version>
  5.     <executions>
  6.         <execution>
  7.             <id>liquibase-postgresql-offline</id>
  8.             <configuration>
  9.                 <changeLogFile>src/main/resources/liquibase/db-changelog-master.xml</changeLogFile>
  10.                 <url>offline:postgresql?changeLogFile=${project.build.directory}/liquibase/postgresql/changelog.csv</url>
  11.                 <migrationSqlOutputFile>${project.build.directory}/liquibase/postgresql/migrate.sql</migrationSqlOutputFile>
  12.                 <outputFileEncoding>UTF-8</outputFileEncoding>
  13.             </configuration>
  14.             <phase>process-resources</phase>
  15.             <goals>
  16.                 <goal>updateSQL</goal>
  17.             </goals>
  18.         </execution>
  19.     </executions>
  20. </plugin>
The error returned by Maven is as follows:

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.4.2:updateSQL (liquibase-postgresql-offline) on project cobalt-database-resource: Execution liquibase-postgresql-offline of goal org.liquibase:liquibase-maven-plugin:3.4.2:updateSQL failed: Failed to get current schema: Cannot execute commands against an offline database -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.liquibase:liquibase-maven-plugin:3.4.2:updateSQL (liquibase-postgresql-offline) on project cobalt-database-resource: Execution liquibase-postgresql-offline of goal org.liquibase:liquibase-maven-plugin:3.4.2:updateSQL failed: Failed to get current schema
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:224)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:317)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:152)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:555)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution liquibase-postgresql-offline of goal org.liquibase:liquibase-maven-plugin:3.4.2:updateSQL failed: Failed to get current schema
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:115)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: java.lang.RuntimeException: Failed to get current schema
at liquibase.database.core.PostgresDatabase.getConnectionSchemaName(PostgresDatabase.java:255)
at liquibase.database.AbstractJdbcDatabase.getDefaultSchemaName(AbstractJdbcDatabase.java:302)
at liquibase.changelog.ChangeLogParameters.<init>(ChangeLogParameters.java:54)
at liquibase.Liquibase.<init>(Liquibase.java:104)
at org.liquibase.maven.plugins.AbstractLiquibaseChangeLogMojo.createLiquibase(AbstractLiquibaseChangeLogMojo.java:81)
at org.liquibase.maven.plugins.LiquibaseUpdateSQL.createLiquibase(LiquibaseUpdateSQL.java:56)
at org.liquibase.maven.plugins.AbstractLiquibaseMojo.execute(AbstractLiquibaseMojo.java:360)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:106)
... 20 more
Caused by: liquibase.exception.DatabaseException: Cannot execute commands against an offline database
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:73)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:117)
at liquibase.executor.jvm.JdbcExecutor.query(JdbcExecutor.java:128)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:136)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:151)
at liquibase.executor.jvm.JdbcExecutor.queryForObject(JdbcExecutor.java:146)
at liquibase.database.core.PostgresDatabase.getConnectionSchemaName(PostgresDatabase.java:250)
... 27 more

I'm able to use offline mode to generate migration SQL scripts for other databases without a problem. I'm also able to do an online migration for PostgreSQL, so the problem seems to be unique to PostgreSQL in offline mode.

Is there something different I need to do to generate offline scripts for PostgreSQL?

Kind Regards

Paul

Re : Unable to generate offline migration script for PostgreSQL database

$
0
0
It appears that this is a bug in the liquibase.database.core.PostgresDatabase class. Most of the other implementations of getConnectionSchemaName() in the Database classes start with a check for an offline connection and return null. 

I have submitted a pull request to fix this - https://github.com/liquibase/liquibase/pull/533

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

3.5.0 release date

$
0
0
Hi guys,

I would be interested when we can expect the release 3.5.0.

We have a custom Liquibase release for OSGi development, but if it is possible, we prefer using the official releases.

About 30 modules of our OpenSource stack are in SNAPSHOT state waiting for the new Liquibase release.

I see that number of unresolved issues that are assigned to version 3.5.0 in Liquibase Jira are growing day-by-day. I am curious if we can expect a release soon. If not, I would give out one more custom Liquibase release to be able to stabilize our modules.

Two issues are blocker for us:

Including the same ChangeSet twice causes ValidationFailedException (CORE-1887)

We provided a patch for this that should be reviewed.

OSGiPackageScanClassResolver does not search extensions in Fragment bundles (CORE-1690)

Luckily this is already merged and would be part of Liquibase 3.5.0.

Thanks and regards,
Balazs



Re : 3.5.0 release date

$
0
0
No official release date yet for 3.5.0, but hoping to wrap it up by the end of the year.

I'll take a look at your pull request for CORE-1887. Some of the issues in 3.5.0 may not make the final version, are there any other issues you want to make sure are included?

Nathan

New utility for testing your Liquibase changelog using H2 and JUnit

$
0
0
Hi everyone!

Some time ago I release an initial version of a new JUnit @Rule that makes it easier to test your DB integration code by setting up an in-memory H2 database to use in your test (see https://github.com/zapodot/embedded-db-junit for more details)..

Guess what? I just added a Liquibase initialization plugin that enables you to run apply your Liquibase change log to the embedded database before running your test code.
Look at this blog post for further details..

Comments and/or suggestions for further development are more than welcome :-)

Sondre

GitHub: zapodot
Twitter: @zapodot

Re : 3.5.0 release date

$
0
0
These two issues are the only ones that are blocker for us.

If you could please notify me somehow (e.g.: message under @Liquibase on twitter) one day before giving out the release, I would re-test if the OSGi Manifest headers are still good. They should be, but with new or removed dependencies with a 2 MB jar codebase, strange things can happen.

Thanks and regards,
Balazs

Re : 3.5.0 release date

$
0
0
Thanks, I'll let you know.

Nathan

MySQL syntax not working for the file based db?

$
0
0
Is it possible that the MySQL mode for the HSQLDB is treated differently for the in memory DB vs file based DB?
The following changeset works fine when executing against the in memory HSLDB but fails when run against file based HSQLDB.
In both cases I'm specifying: sql.syntax_mys=true as the connection param.
<changeSet author="sb" id="changeSet_id">
<createTable tableName="SAMPLE_TABLE">
<column name="KEY" type="VARCHAR(255)">
<constraints nullable="false" primaryKey="true"/>
</column>
<column name="VALUE" type="VARCHAR(255)">
<constraints nullable="false"/>
</column>
</createTable>
</changeSet>
When executed against filebased HSQLDB then it complains that 255 is incorrect character.
Basically the name of the column "Key" is not getting escaped which does happen when run against in memory HSQLDB.
I'm using HSQLDB v 2.3.3 and Liquibase-maven-plugin v3.4.1 to apply schema changes.

SQL scripts should have "USE " in the header on SQL Server

$
0
0
Hello,

there is a ticket for this topic https://liquibase.jira.com/browse/CORE-2451. This was merged and released in 3.4.1, but I think this should be optional.

We use Liquibase to generate SQL and we don't know the target database name and we don't have execution of SQL under control. We only have copy of database which we use to generate SQL scripts and we keep it in sync.

So my goal is to remove "USE [database]", because it is integrator responsibility to run thw script under right database.

Any idea how to live with this. Ok, I can remove it from SQL script manually, but...

Thanks to all

Michael

Liquibase spring bean "log" property

$
0
0
Hi,

I've currently managed to configure my Spring application to work with liquibase in a way that it runs the update command whenever I start the application. The problem is that I'd like to be able to see the output log from liquibase in a different file in order to be able to clearly see what has happened to my database, without having to search the entire startup log that can get really big in size. Could you explain a bit how the "log" property of the spring bean works? 

Currently I have in my log4j.properties file a line like this:
      log4j.appender.liquibase=org.apache.log4j.RollingFileAppender
and I would like to use this as my default liquibase logger.
Any help or insight on this matter?

Thanks in advance.

Re : Liquibase spring bean "log" property

$
0
0
I am not sure about the log property. I don't see it on the SpringLiquibase class or the Liquibase class. I can give you a bit of info on how to get logging routing to Log4J.

Liquibase 3.x has its own logging implementation that uses no external logging dependencies. The default logger logs to standard out (which is what I suspect you are seeing now). In order to route Liquibase logs to another logging framework you need to place an adapter jar on your classpath. I did some searching and found a couple of links about the log4j logging adapter:

Maven Central - Log4j Liquibase
Liqubase Wiki on Logging extensions

If you are using SLF4J as a logging facade there is also an extension to route Liquibase logs to that (Full Disclosure: I wrote that library).

Github - liquibase-slf4j

Once the adapter jar is on your classpath, the configuration you have defined above should start to function as you expect.

I hope this helps.

More database objects support

$
0
0
Hi,
I've found that the enterprise solution (datical) does support almost all of the database objects (domains, enums, triggers, ...), but because it is enterprise solution, I'm affraid that prices will be in thousdands or ten of thousands.

I would welcome some more advanced liquibase (optionally paid) version where only all database objects are supported from the enterprise version and nothing else. Would something like this be possible in the future? Or could we somehow sponsor addition of other database objects in OSS liquibase version?

Thank You

Liquibase Dryrun

$
0
0
Hello Users/Developers,

How do you do dry-run Liquibase to make sure that all the tags are valid before check-in your code to GIT?

Thanks,
Mahendra

Re : Liquibase Dryrun

$
0
0
Many developers will do a "dry run" by deploying to a local dev database. Most DB engines have a free developer version that can be used for this sort of testing. The other option is to use the option to just generate SQL rather than actually running the SQL. 

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

Re : changelog filename in database contains full OS path?

$
0
0
I know this is an old thread however, I am having the same issue using the Gradle plugin.  It seems to behave differently depending on if I run the script from the parent project or within the sub-project.  If I run it inside the subproject, it uses an absolute path.  If I run from the parent project, it uses the shorter path (like "src/db/main/changelogs/changelogxyz.sql").

This seems to cause a ton of grief for people including myself.  I wished it was as simple as absolutePath="true"/"false"
Viewing all 2993 articles
Browse latest View live