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

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

Viewing all articles
Browse latest Browse all 2993

Trending Articles



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