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

Re : CDILiquibase not reliable working

$
0
0
I personally have no familiarity at all with CDI, so I can't really help. 

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

Re : CDILiquibase not reliable working

$
0
0
Hello Steve,

thanks for your reply. The question was not to CDI it was how to get rid the CDI.
Means what type of startup in a EJB containter do you suggest?
I know this: http://www.liquibase.org/documentation/running.html

Means are the more options of integrating it directly into a EJB (without CDI)?

best wishes

Re : CDILiquibase not reliable working

$
0
0
Again, not something in my realm of expertise. There may be other people here who can answer, but I would suggest that StackOverflow probably gets more traffic, especially around EJB containers and Liquibase.

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

rollback on error

$
0
0
Is there a way to completion LiquiBase after a failed update command is automatically launched rollback?

Liquibase Update command not executing rollback changesets

$
0
0
Hi, I have the following changelog :

<?xml version="1.0" encoding="utf-8" standalone="no"?>
  <changeSet author="Paulo.Tavares (generated)" id="1445961538397-1">
    <createTable tableName="test">
      <column name="FieldName" type="VARCHAR(50)" />
    </createTable>
  </changeSet>
  <changeSet id="test-1111" author="Paulo">
    <createTable tableName="table_test_commit">
      <column name="contacto" type="VARCHAR(50)" />
    </createTable>
  </changeSet>
  <changeSet id="test-1111-rollback" author="Paulo">
    <rollback changeSetId="test-1111" changeSetAuthor="Paulo" />
  </changeSet>
</databaseChangeLog>

When I execute the update command with this changelog I want it to be able to rollaback the selected changeset by dropping the created table but it's not working, Is that possible or is there another way to do it that I'm missing?

Re : Liquibase Update command not executing rollback changesets

$
0
0
By specifying an empty rollback tag, you have effectively told Liquibase "this does not need to be rolled back". Since the createTable change can automatically be rolled back, just removing the rollback tag should accomplish what you want. If you wanted to do more than just drop the table on rollback, you could add more to the rollback tag.

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

Re : CDILiquibase not reliable working

$
0
0
Looking at the code for CDILiquibase, it checks the liquibase.shouldRun flag and if it is false, it does not execute. 

Your easiest route would be to either set the liquibase.shouldRun system property to "false", or call 

  1. LiquibaseConfiguration.getInstance().getConfiguration(GlobalConfiguration.class).setShouldRun(false)
from somewhere in your code that executes before the CDI bootstrapping happens, possibly in a class's static{} block?

Nathan

Nathan

Re : Liquibase Update command not executing rollback changesets

$
0
0
Actually, the rollback tag isn't empty, it is referencing a changelog. That is telling liquibase that to rollback changeSet "test-1111-rollback" you execute what is in "test-1111" which creates the table. 

Steve's answer is still correct, though. You don't need the test-1111-rollback changeSet at all. Take it out and Liquibase automatically knows how to rollback test-1111 if you ask it to.

Nathan

How do I get Liquibase to print out the SQL it generated?

$
0
0

Hi,


I’m using Gradle 2.7, the Liquibase 1.1.1 plugin and attempting to run my changeset on an Apache Derby (v. 10.12.1.1) in-memory database.  Running the following changeSet fails immediately on the first changeSet …


[code]

        <changeSet author="my" id="add_my_project_address">

                <createTable tableName="my_project_address">

            <column defaultValue="" name="id" type="VARCHAR(32)">

                <constraints nullable="false" primaryKey="true"/>

            </column>

            <column defaultValue="" name="address" type="VARCHAR(500)">

                <constraints nullable="true"/>

            </column>

            <column defaultValue="" name="city" type="VARCHAR(100)">

                <constraints nullable="true"/>

            </column>

            <column defaultValue="" name="state" type="VARCHAR(10)">

                <constraints nullable="true"/>

            </column>

            <column defaultValue="" name="zip" type="VARCHAR(10)">

                <constraints nullable="true"/>

            </column>

            <column defaultValue="" name="lattitude" type="INT UNSIGNED">

                <constraints nullable="true"/>

            </column>

            <column defaultValue="" name="longitude" type="INT UNSIGNED">

                <constraints nullable="true"/>

            </column>

            <column defaultValue="" name="email" type="VARCHAR(200)">

                <constraints nullable="true"/>

            </column>

            <column defaultValue="" name="phone" type="VARCHAR(32)">

                <constraints nullable="true"/>

            </column>

            <column defaultValue="" name="phone_type" type="VARCHAR(10)">

                <constraints nullable="true"/>

            </column>

                </createTable>

        </changeSet>

[/code]


How can I configure Liquibase to output the SQL generated?  Here is how I have set up the plugin …


[code]

liquibase {

  activities {

    main {

      File propsFile = new File("${project.rootDir}/src/main/environment/${environment}/liquibase.properties")

      Properties properties = new Properties()

      properties.load(new FileInputStream(propsFile))

      changeLogFile 'src/main/resources/db.changelog-master.xml'

      url properties['url']

      username properties['username']

      password properties['password']

    }

    test {

      File propsFile = new File(liquibasePropertiesFile)

      Properties properties = new Properties()

      properties.load(new FileInputStream(propsFile))

      changeLogFile 'src/main/resources/db.changelog-master.xml'

        url 'jdbc:derby:memory:test-jpa;create=true'

        username 'sa'

    }

    runList = 'main,test'

  }

}

[/code]


For what its worth, this is all Liquibase tells me when the above is run …


[code]

SEVERE 10/27/15 4:02 PM: liquibase: src/main/resources/db.changelog-master.xml: src/main/resources/db.changelog-1.0.xml::add_my_project_address::my: Change Set src/main/resources/db.changelog-1.0.xml::add_my_project_address::my failed.  Error: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "," at line 1, column 224.

liquibase.exception.DatabaseException: java.sql.SQLSyntaxErrorException: Syntax error: Encountered "," at line 1, column 224.

at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:316)

at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)

at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:122)

at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1227)

at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1210)

at liquibase.changelog.ChangeSet.execute(ChangeSet.java:550)

at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:43)

at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:73)

at liquibase.Liquibase.update(Liquibase.java:200)

at liquibase.integration.commandline.Main.doMigration(Main.java:1044)

at liquibase.integration.commandline.Main.run(Main.java:175)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

at java.lang.reflect.Method.invoke(Method.java:497)

at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:90)

at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:324)

at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.invoke(StaticMetaMethodSite.java:43)

at org.codehaus.groovy.runtime.callsite.StaticMetaMethodSite.call(StaticMetaMethodSite.java:88)

at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:116)

at org.liquibase.gradle.LiquibaseTask.runLiquibase(LiquibaseTask.groovy:97)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)

at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

[/code]

Re : How do I get Liquibase to print out the SQL it generated?

Drop-create data after each test with SpringLiquibase

$
0
0

I'm using Springliquibase 3.3.2. I read the datas for db in csv files.

I have unit tests running with SpringLiquibase and I wanted the database returned to it's initial state after each test run.

I'm setting dropFirst == true and was expecting this to restore the hsql db but it does not. I see data changes in one test that were performed in previous tests. My code to define the SpringLiquibase :

@Configuration

@EnableJpaRepositories(basePackages={"my.package"})
@EntityScan(basePackages={"my.package"})
@EnableTransactionManagement
public class DatabaseConfiguration implements EnvironmentAware {
private RelaxedPropertyResolver propertyResolver;
 
private Environment env;
 
private DataSource dataSource;
private SpringLiquibase springLiquibase;
 
@Autowired(required = false)
private MetricRegistry metricRegistry;
 
@Override
public void setEnvironment(Environment env) {
    this.env = env;
    this.propertyResolver = new RelaxedPropertyResolver(env, "spring.datasource.");
}
 
@Bean(destroyMethod = "shutdown")
@ConditionalOnMissingClass(name = "fr.ticks.pp.front.config.HerokuDatabaseConfiguration")
@Profile("!" + "cloud")
public DataSource dataSource() {
    log.debug("Configuring Datasource");
    if (propertyResolver.getProperty("url") == null && propertyResolver.getProperty("databaseName") == null) {
        log.error("Your database connection pool configuration is incorrect! The application" +
                "cannot start. Please check your Spring profile, current profiles are: {}",
                Arrays.toString(env.getActiveProfiles()));
 
        throw new ApplicationContextException("Database connection pool is not configured correctly");
    }
    HikariConfig config = new HikariConfig();
    config.setDataSourceClassName(propertyResolver.getProperty("dataSourceClassName"));
    if (propertyResolver.getProperty("url") == null || "".equals(propertyResolver.getProperty("url"))) {
        config.addDataSourceProperty("databaseName", propertyResolver.getProperty("databaseName"));
        config.addDataSourceProperty("serverName", propertyResolver.getProperty("serverName"));
    } else {
        config.addDataSourceProperty("url", propertyResolver.getProperty("url"));
    }
    config.addDataSourceProperty("user", propertyResolver.getProperty("username"));
    config.addDataSourceProperty("password", propertyResolver.getProperty("password"));
 
    if (metricRegistry != null) {
        config.setMetricRegistry(metricRegistry);
    }
 
    dataSource = new HikariDataSource(config);
    return dataSource;
}
 
@Bean
public SpringLiquibase liquibase(DataSource dataSource) {
    SpringLiquibase liquibase = new SpringLiquibase();
    liquibase.setDataSource(dataSource);
    liquibase.setChangeLog("classpath:config/liquibase/master.xml");
    liquibase.setContexts("development, production");
    // ne lance liquibase que si on utilise H2 en mémoire
    boolean runningH2 = isRunningH2();
    liquibase.setShouldRun(runningH2);
    if (runningH2) {
        log.debug("Configuring Liquibase for H2");
    }
 
    return liquibase;
}

And my test file :

@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = Application.class)
@WebAppConfiguration
@IntegrationTest
public abstract class AbstractPPTest
{
 
  @Autowired
  protected ApplicationContext applicationContext;
 
  protected MockWebServiceClient mockClient;
 
  @Before
  public void initMock()
  {
    assertNotNull(applicationContext);
    mockClient = MockWebServiceClient.createClient(applicationContext);
    testDate = Calendar.getInstance();
  }
 
@Test
public void test
{
...
}


Is there a non-manual (or manual) way to reset the data between tests in test files ?

Thanks

Inheritable contexts

$
0
0
I've created a pull request for an older feature request that will make it possible for change sets to inherit contexts from the databaseChangeLog, include and includeAll elements. I think this will help productivity as the number of change logs and change sets increases. I'm looking for feedback. Thank you.

Latest MySQL Error on Setting Tags

$
0
0
Looks like Liquibase had this issue a long time ago. We run our migration tests out of the latest mysql dockers for dev. The most resent update now gives the following error when setting a tag.

Error: Error executing SQL UPDATE xps_customer.DATABASECHANGELOG SET TAG = 'v2.0.0' WHERE DATEEXECUTED = (SELECT MAX(DATEEXECUTED) FROM (SELECT DATEEXECUTED FROM xps_customer.DATABASECHANGELOG) AS X): You can't specify target table 'DATABASECHANGELOG' for update in FROM clause
liquibase.exception.DatabaseException: Error executing SQL UPDATE xps_customer.DATABASECHANGELOG SET TAG = 'v2.0.0' WHERE DATEEXECUTED = (SELECT MAX(DATEEXECUTED) FROM (SELECT DATEEXECUTED FROM xps_customer.DATABASECHANGELOG) AS X): You can't specify target table 'DATABASECHANGELOG' for update in FROM clause
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:62)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:122)
at liquibase.database.AbstractJdbcDatabase.execute(AbstractJdbcDatabase.java:1206)
at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1189)
at liquibase.changelog.ChangeSet.execute(ChangeSet.java:528)
at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:43)
at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:70)
at liquibase.Liquibase.update(Liquibase.java:195)
at liquibase.Liquibase.update(Liquibase.java:174)
at liquibase.integration.commandline.Main.doMigration(Main.java:997)
at liquibase.integration.commandline.Main.run(Main.java:170)
at liquibase.integration.commandline.Main.main(Main.java:89)
Caused by: java.sql.SQLException: You can't specify target table 'DATABASECHANGELOG' for update in FROM clause
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1094)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4226)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4158)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2615)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2776)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2834)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2783)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:908)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:788)
at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:310)
at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
... 11 more

Cannot pass property using -Dproperty=value

$
0
0
When I try to run Liquibase on the command line passing a property using the -D switch I always get an error:

  1. liquibase -Dtable_owner=foo --defaultsFile=connection.properties --changeLogFile=changelog.xml update

results in the error:

Errors:
  Unexpected value -Dtable_owner=foo: parameters must start with a '--'

Usage: java -jar liquibase.jar [options] [command]
(Needless to say that --Dtable_owner=foo doesn't work either)

When I try the -D at the end of the line (as shown here)

  1. liquibase --defaultsFile=connection.properties --changeLogFile=changelog.xml update -Dtable_owner=foo

I get the error:


Unexpected error running Liquibase: Unknown parameter: 'table_owner'

SEVERE 11/3/15 10:41 AM: liquibase: Unknown parameter: 'table_owner'
liquibase.exception.CommandLineParsingException: Unknown parameter: 'table_owner'
        at liquibase.integration.commandline.Main.parsePropertiesFile(Main.java:453)
        at liquibase.integration.commandline.Main.run(Main.java:159)
        at liquibase.integration.commandline.Main.main(Main.java:99)


What am I missing?
I am using Liquibase 3.4.1

How do I pass a parameter (that is used with "${table_owner}" in the changeLog) on the command line?


Re : Cannot pass property using -Dproperty=value

$
0
0
I think you need to specify the parameters after the "update" command, so:

  1. liquibase --defaultsFile=connection.properties --changeLogFile=changelog.xml update -Dtable_owner=foo

Re : Cannot pass property using -Dproperty=value

$
0
0
Thanks for the answer. I did try that and also got an error - but that was unrelated to my commandline. My properties file contained a line "table_owner: foo" which caused the error. Passing -D after the update command indeed does work.

Sorry for the noise.

Re : Can I add changelog property to liquibase.properties file?

$
0
0
I had the same requirement, and after looking at the source code, I found out that this is possible if the property key is prefixed with "parameter":

  1. #Liquibase.properties
  2. driver: oracle.jdbc.OracleDriver
  3. classpath: ojdbc7.jar
  4. url: jdbc:oracle:thin:@10.0.2.1:1521:mydb
  5. username: USER
  6. password: pswd
  7. parameter.connection_string: user/pswd@mydb

Liquibase problems with converting TINYINT(1) to BIT

$
0
0
Deciding to treat TINYINT as BIT seems not to be working.

Liquibase: Data truncation: Data too long for column 'LOCKED' at row 1 [Failed SQL: INSERT INTO hgigoc.databasechangeloglock (ID, LOC
KED, LOCKGRANTED, LOCKEDBY) VALUES ('1', '0', NULL, NULL)]

Please, review the idea of treating TINYINT as BIT since all it acomplishes is making problems.

Liquibase unknown database error.

$
0
0
Hi ,

I am using liquibase 3.4.1 but I got one issue regarding database , my database  name is combination of small & capital letters.
While running liquibase update it is showing unknown database error . It converts all letters into small case. We are using
mysql database server. 

Following is the error log

DEBUG 26/11/15 3:08 PM: liquibase: Release Database Lock
DEBUG 26/11/15 3:08 PM: liquibase: Executing UPDATE database command: UPDATE myTestDB.DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1
INFO 26/11/15 3:08 PM: liquibase: Successfully released change log lock
Unexpected error running Liquibase: java.sql.SQLException: Unknown database 'mytestdb'

SEVERE 26/11/15 3:08 PM: liquibase: java.sql.SQLException: Unknown database 'mytestdb'
liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: java.sql.SQLException: Unknown database 'mytestdb'
at liquibase.changelog.StandardChangeLogHistoryService.init(StandardChangeLogHistoryService.java:102)
at liquibase.Liquibase.checkLiquibaseTables(Liquibase.java:1074)
at liquibase.Liquibase.update(Liquibase.java:203)
at liquibase.Liquibase.update(Liquibase.java:190)
at liquibase.integration.commandline.Main.doMigration(Main.java:1096)
at liquibase.integration.commandline.Main.run(Main.java:180)
at liquibase.integration.commandline.Main.main(Main.java:99)
Caused by: liquibase.exception.DatabaseException: java.sql.SQLException: Unknown database 'mytestdb'
at liquibase.snapshot.ResultSetCache.get(ResultSetCache.java:78)
at liquibase.snapshot.JdbcDatabaseSnapshot$CachingDatabaseMetaData.getTables(JdbcDatabaseSnapshot.java:343)
at liquibase.snapshot.jvm.TableSnapshotGenerator.snapshotObject(TableSnapshotGenerator.java:32)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:60)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:63)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:63)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:63)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:63)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:63)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:63)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:50)
at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:194)
at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:70)
at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:44)
at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:21)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:150)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:158)
at liquibase.snapshot.SnapshotGeneratorFactory.getDatabaseChangeLogTable(SnapshotGeneratorFactory.java:165)
at liquibase.changelog.StandardChangeLogHistoryService.init(StandardChangeLogHistoryService.java:100)
... 6 more
Caused by: java.sql.SQLException: Unknown database 'mytestdb'
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2847)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1531)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1622)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2370)
at com.mysql.jdbc.Connection.execSQL(Connection.java:2297)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:1183)
at com.mysql.jdbc.DatabaseMetaData.getTables(DatabaseMetaData.java:3351)
at liquibase.snapshot.JdbcDatabaseSnapshot$CachingDatabaseMetaData$4.fastFetchQuery(JdbcDatabaseSnapshot.java:365)
at liquibase.snapshot.ResultSetCache$SingleResultSetExtractor.fastFetch(ResultSetCache.java:290)
at liquibase.snapshot.ResultSetCache.get(ResultSetCache.java:58)
... 30 more
Please can someone help me ?

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

$
0
0
A lot of tools like Toad generates pl/sql scripts with slash after pl/sql blocks. But liquibase adds ; after slash and after compilation object is invalid. Shouls I always manually remove slash? Is there a better way?
Viewing all 2993 articles
Browse latest View live


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