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

Re : Understanding validCheckSum

$
0
0
The validCheckSum tag is not included in the checksum computation, so it should not change by adding the tag.

Nathan

Re : Support Oracle 12c feature identity (autoincrement)

$
0
0
If liquibase doesn't support a feature in the built in tags like <createTable>, you can always fall back to the <sql> tag to specify exactly what you want. You lose some cross-database support and since liquibase doesn't understand what is being ran you don't get automatic rollback or dbdoc support.

If you are looking to try to add support, it may be as simple as updating https://github.com/liquibase/liquibase/blob/master/liquibase-core/src/main/java/liquibase/database/core/OracleDatabase.java to return "true" on supportsAutoIncrement with an appropriate version check. If you are able to get it to work, send a pull request and I'll include it in 3.2.0

Nathan

Questions about liquibase core classes

$
0
0
Hello

I have some doubts about liquibase core classes:

  • Why does liquibase.changelog.Changeset#getChanges return an unmodifiableList since I'd like to manipulate (directly delete or edit+update a change)?
  • Why doesn't liquibase.change.Change implementation has not an identifier, since I am using this classes directly binded in JSF pages?
  • When using N changes within a changeset, could I use <preConditions> tag? Is there any alternative or do I need to implement 1-1 change-changeset?
  • Is it possible to preview SQL generation by passing Change implementation and Database object somewhere?

Re : diff usage: dialect path

$
0
0
maven-3.0.4
liquibase-maven-plugin-3.1.1
and liquibase-3.1.1
liquibase-hibernate3-3.2

Now I've fixed that error. never mind. That was incorrect plugin issue due I was using modified liquibase-hibernate extension. When using all native libraries, (written by you, Nathan and community)
it appears Nullpoinet error like next:
  1. -
  2. [INFO] ------------------------------------------------------------------------
  3. [INFO] Settings----------------------------
  4. [INFO]     driver: net.sourceforge.jtds.jdbc.Driver
  5. [INFO]     url: jdbc:jtds:sqlserver://localhost:1433/sample
  6. [INFO]     username: sa
  7. [INFO]     password: *****
  8. [INFO]     use empty password: false
  9. [INFO]     properties file: null
  10. [INFO]     properties file will override? false
  11. [INFO]     prompt on non-local database? true
  12. [INFO]     clear checksums? false
  13. [INFO]     changeLogFile: src/main/resources/db/migration/rlm-changelog.xml
  14. [INFO]     context(s): null
  15. [INFO]     referenceDriver: null
  16. [INFO]     referenceUrl: hibernate:spring:com.my.rlm.dao.entities?dialect=org.hibernate.dialect.SQLServer2008Dialect
  17. [INFO]     referenceUsername: sa
  18. [INFO]     referencePassword: sa
  19. [INFO]     referenceDefaultSchema: null
  20. [INFO]     diffChangeLogFile: src/main/resources/db/migration/rlm-5.0.1-changelog.xml
  21. [INFO] ------------------------------------------------------------------------
  22. [INFO] Executing on Database: jdbc:jtds:sqlserver://localhost:1433/sample
  23. [INFO] Loading artfacts into URLClassLoader
  24. ....
  25. [INFO] ------------------------------------------------------------------------
  26. [INFO] BUILD FAILURE
  27. [INFO] ------------------------------------------------------------------------
  28. [INFO] Total time: 8.882s
  29. [INFO] Finished at: Wed Feb 05 21:38:35 EET 2014
  30. [INFO] Final Memory: 16M/604M
  31. [INFO] ------------------------------------------------------------------------
  32. [ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.1.1:diff (default-cli) on project rlm-service: Error setting up or running Liquibase: java.lang.NullPointerException -> [Help 1]
  33. [ERROR] 
  34. [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
  35. [ERROR] Re-run Maven using the -X switch to enable full debug logging.
  36. [ERROR] 
  37. [ERROR] For more information about the errors and possible solutions, please read the following articles:
  38. [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Re : Questions about liquibase core classes

$
0
0
ChangeSet.getChanges is read only because the code has not necessarily been tested with dynamic changes to the list of changes in it. There is a ChangeSet.addChanges method to add a change but not anything to remove it currently. The list returned is not modifiyable but the Changes contained in it can be edited.

Changes do not have identifiers because they have not been needed so far. ChangeSets have a unique identifier and are tracked by liquibase, but the change implementations are just anonymously contained in the ChangeSet. If they had a unique identifeir, it would probably just be ChangeSet.id+ChangeSet.author+ChangeSet.filePath+indexOfChange

Preconditions are only at the changeSet level because that is the level liquibase works at and tries to run as a transaction. If you want preconditions per change you will need to have just one change per changeSet (most of the time you want this anyway because DDL statements autocommit which can get liquibase into a bad state if a second change fails).

There are several ways to preview SQL generation. If you have a Change object, calling change.generateStatements(database) will return an array of statements, each of which can be passed to SqlGeneratorFactory.getInstance().generateSql(statement, database) 

Nathan

varchar handling for reverse engineered Oracle tables

$
0
0
Hi,
just a short question:
When I reverse engineer a Oracle database table with a varchar2 column, I get a column type that includes VARCHAR2 and even the CHAR parameter (if the column was defined as CHAR and not as BYTE).
This is great for Oracle databases!


    <changeSet author="chris" id="1390834713831-154">
        <createTable  tableName="SOME_TABLE">     
            <column name="TEXT_COL" type="VARCHAR2(120 CHAR)">
                <constraints nullable="false"/>
            </column>          
        </createTable>
    </changeSet>

But if I try to run this against a postgres database, the script fails because postgres does not know the CHAR param.
The conversion from VARCHAR2 to VARCHAR is done correctyl in the generated postgres SQL but the CHAR param breaks it.

Is it possible to filter the CHAR param for databases that do not support ist?

Best regards,
Chris

calling pragma before anything else ?

$
0
0
Hi,

First I would like to say many thanks to the developers of liquibase, it is extremely useful to me, and saves me a lot of time!

My context of use is with a sqlite database encrypted with sqlcipher. For this i have to call "PRAGMA key = 'xxxxxx';" before any operation on database.
Until now I hardcoded this pragma in the jdbc driver in the open function inside sqlite/DB.java
This is not a good solution, because the database encryption becomes nearly useless: any-one can use the jdbc driver to read the database without knowing the encryption key. My intention is now to remove this pragma from the jdbc driver.
How can I make liquibase call this pragma before anything else ?
I tried the following solutions without success:
-creating a changset with runAlways="true" containing <sql>PRAGMA key = 'xxxx';</sql>. It does not work because liquibase queries the database before the first changeset is executed
-creating a changelog level preConditions tag, containing sqlCheck. It does not seem to work, maybe because sqlCheck expects a single row with a single value in return. What's more I am not sure it is run before any other database access

Would you have any direction for me to test?

Thanks in advance !
Eric Lemanissier

Re : diff usage: dialect path

$
0
0
Does anybody know a real example where liquibase diff works using maven-plugin, spring and hibernate?
I'm pretty unsuccessfull with trying to configure it. Does not matter what DB I'm using. Oracle or MSSQL.
If danybody knows, please show me the учфьзду settings.
On my properties set I showed in previous message liquibase:generateChangeLog works well.

Re : PreConditions not working with outputfile

$
0
0
Nathan

The gold question is: why precondition isn't wrote in outputfile?

Re : Liquibase preconditions not working

$
0
0
It's not the expected result?

  • onFail="CONTINUE" 

Liquibase support for CLOB data

$
0
0
I have several relations that contain CLOB data.  I would like to insert data into these CLOB fields with INSERT and/or LOAD DATA.  I have noticed several postings that mention an attribute of COLUMN called "valueClob".  However, when I use that attribute the parser complains:

Liquibase updateSql Failed: Error parsing line 25 column 71 of insertChangeSet.xml: cvc-complex-type.3.2.2: Attribute 'valueClob' is not allowed to appear in element 'column'.

The line in question contains:

<column name="TEMPLATE" valueClob="clobData.xml" type="CLOB"/>  


I am using Liquibase version 3.1.1 with reference to the XSD version 3.1.  Am I doing something wrong?

Re : Liquibase support for CLOB data

$
0
0
Nevermind.  I downloaded the XSD and saw many "refactorings" that aren't in the documentation such as valueClobFile.  With a little more reengineering I found the correct syntax and action.

Re : Ant- update database outputDefaultSchema property

$
0
0
Thanks Nathan, I'll do the find and replace.

Re : Ant- update database outputDefaultSchema property

Re : Using Maven security?

$
0
0
I took some time to examine this and I tested it with Maven 2.2.1 and Maven 3.0.x and in both cases the passwords decryption already worked. The WagonManager class used handles the decryption as far as I can tell. Doesn't look like any work is needed at this point in time. If others are still having issues I would love to know some more specifics.

dropAll fails on RedShift

$
0
0
Hi,

I would like to execute dropAll on our RedShift DB, and I get this strange error. Unfortunatelly I don't even see from the debug output what SQL statement is causeing the problem (see below). On one line it states "Successfully released change log lock", on the next line: "Liquibase dropAll Failed: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: Unable to determine a value for MaxIndexKeys due to missing system catalog data."

here's the debug output:

$ liquibase --defaultsFile=redshift.properties --logLevel=debug dropAll
DEBUG 2/10/14 3:05 PM:liquibase: Connected to innotest@jdbc:postgresql://idan-rf-test.cthrquit7zzo.us-east-1.redshift.amazonaws.com:5439/gavriel_systemtest
DEBUG 2/10/14 3:05 PM:liquibase: Setting auto commit to false from true
DEBUG 2/10/14 3:05 PM:liquibase: Executing QUERY database command: select count(*) from public.databasechangeloglock
DEBUG 2/10/14 3:05 PM:liquibase: Executing QUERY database command: SELECT LOCKED FROM public.databasechangeloglock WHERE ID=1
DEBUG 2/10/14 3:05 PM:liquibase: Lock Database
DEBUG 2/10/14 3:05 PM:liquibase: Executing UPDATE database command: UPDATE public.databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = 'galaxy (fe80:0:0:0:800:27ff:fe00:0%4)', LOCKGRANTED = '2014-02-10 15:05:16.282' WHERE ID = 1 AND LOCKED = FALSE
INFO 2/10/14 3:05 PM:liquibase: Successfully acquired change log lock
INFO 2/10/14 3:05 PM:liquibase: Dropping Database Objects in schema: gavriel_systemtest.public
DEBUG 2/10/14 3:05 PM:liquibase: Executing QUERY database command: SELECT MD5SUM FROM public.databasechangelog WHERE MD5SUM IS NOT NULL
DEBUG 2/10/14 3:05 PM:liquibase: Executing QUERY database command: select count(*) from public.databasechangeloglock
DEBUG 2/10/14 3:05 PM:liquibase: Executing QUERY database command: SELECT relname AS SEQUENCE_NAME FROM pg_class, pg_namespace WHERE relkind='S' AND pg_class.relnamespace = pg_namespace.oid AND nspname = 'public' AND 'nextval(''public.'||relname||'''::regclass)' not in (select adsrc from pg_attrdef where adsrc is not null) AND 'nextval(''public."'||relname||'"''::regclass)' not in (select adsrc from pg_attrdef where adsrc is not null) AND 'nextval('''||relname||'''::regclass)' not in (select adsrc from pg_attrdef where adsrc is not null)AND 'nextval(''"'||relname||'"''::regclass)' not in (select adsrc from pg_attrdef where adsrc is not null)
DEBUG 2/10/14 3:05 PM:liquibase: Release Database Lock
DEBUG 2/10/14 3:05 PM:liquibase: Executing UPDATE database command: UPDATE public.databasechangeloglock SET LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1
INFO 2/10/14 3:05 PM:liquibase: Successfully released change log lock
Liquibase dropAll Failed: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: Unable to determine a value for MaxIndexKeys due to missing system catalog data.
SEVERE 2/10/14 3:05 PM:liquibase: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: Unable to determine a value for MaxIndexKeys due to missing system catalog data.
liquibase.exception.DatabaseException: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: Unable to determine a value for MaxIndexKeys due to missing system catalog data.
at liquibase.Liquibase.dropAll(Liquibase.java:685)
at liquibase.Liquibase.dropAll(Liquibase.java:665)
at liquibase.integration.commandline.Main.doMigration(Main.java:831)
at liquibase.integration.commandline.Main.main(Main.java:133)
Caused by: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: Unable to determine a value for MaxIndexKeys due to missing system catalog data.
at liquibase.database.AbstractJdbcDatabase.dropDatabaseObjects(AbstractJdbcDatabase.java:719)
at liquibase.Liquibase.dropAll(Liquibase.java:678)
... 3 more
Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: Unable to determine a value for MaxIndexKeys due to missing system catalog data.
at liquibase.snapshot.jvm.ForeignKeySnapshotGenerator.addTo(ForeignKeySnapshotGenerator.java:86)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:72)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:47)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:62)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:47)
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:62)
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:47)
at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:131)
at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:199)
at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:212)
at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:158)
at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:145)
at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:36)
at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:24)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:129)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:122)
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:110)
at liquibase.database.AbstractJdbcDatabase.dropDatabaseObjects(AbstractJdbcDatabase.java:716)
... 4 more
Caused by: liquibase.exception.DatabaseException: org.postgresql.util.PSQLException: Unable to determine a value for MaxIndexKeys due to missing system catalog data.
at liquibase.snapshot.ResultSetCache.get(ResultSetCache.java:73)
at liquibase.snapshot.JdbcDatabaseSnapshot$CachingDatabaseMetaData.getForeignKeys(JdbcDatabaseSnapshot.java:57)
at liquibase.snapshot.jvm.ForeignKeySnapshotGenerator.addTo(ForeignKeySnapshotGenerator.java:75)
... 21 more
Caused by: org.postgresql.util.PSQLException: Unable to determine a value for MaxIndexKeys due to missing system catalog data.
at org.postgresql.jdbc2.AbstractJdbc2DatabaseMetaData.getMaxIndexKeys(AbstractJdbc2DatabaseMetaData.java:64)
at org.postgresql.jdbc2.AbstractJdbc2DatabaseMetaData.getImportedExportedKeys(AbstractJdbc2DatabaseMetaData.java:3187)
at org.postgresql.jdbc2.AbstractJdbc2DatabaseMetaData.getImportedKeys(AbstractJdbc2DatabaseMetaData.java:3517)
at liquibase.snapshot.JdbcDatabaseSnapshot$CachingDatabaseMetaData$1.fastFetch(JdbcDatabaseSnapshot.java:89)
at liquibase.snapshot.ResultSetCache.get(ResultSetCache.java:51)
... 23 more


For more information, use the --logLevel flag

Re : Questions about liquibase core classes

$
0
0
ChangeSet.getChanges - is there any way to get these changes without "brute force" (like using reflection or internet workarounds for unmodifiablelist)?

Since you said that the best practice is to do one change within one changeset, I'll have to change it! :-)

Ok, changing to 1 change within 1 changeset solves my gap. But there is another question (I don't know if I should open another thread): preConditions work as a separated transaction whose decide if Change will be run. But when I am only using Liquibase.update(context, writer) to generate output scripts? Preconditions tag is not being rendered as "if (mycondition) then *my change*. How can I do it by using main liquibase call?
PS: Maybe I could generate it all by my self by create an extension by calling SqlGeneratorFactory.getInstance().generateSql(change.generateStatements) and mounting my output files. Not sure if it is the best practice.

Is it a bad practice to generate my own output files by using SqlGeneratorFactory.generateSql instead of Liquibase.update? Then after when I choose to run all these stuff directly to Database I can call Liquibase.update. 

Re : Generating SQL file per changeset

$
0
0
Yes, you can do by:

  1. calling constructor Liquibase.update(context. writer), since writer will be who will write your physical file.
or

      2. call change.generateStatements(database) (where change will be liquibase core class), then pass these statements to SqlGeneratorFactory.getInstance().generateSql(statement, database) 
P.S.: I just had tested in 3.1.1 liquibase core version

Accumulo support?

$
0
0
Could there be a driver for Accumulo? I would like to use liquibase to diff Accumulo databases.

Liquibase commandline: diff

$
0
0
Hi, colleagues. I have quistion regarding diff or diffChangeLog usage from liquibase commandline tool.
I have latest liquibase unzipped on my pc and I've put need drivers into lib folder.

So, here is my liquibase properties:
  1. driver=net.sourceforge.jtds.jdbc.Driver
  2. classpath=jtds-1.3.1.jar
  3. changeLogFile=../my-service/src/main/resources/db/migration/my-changelog.xml
  4. url=jdbc:jtds:sqlserver://localhost:1433/sample
  5. username=sa
  6. password=sa
  7. referenceUrl=hibernate:spring:com.my.dao.entities
  8. referenceDriver=net.sourceforge.jtds.jdbc.Driver
  9. referenceUsername=sa
  10. referencePassword=sa
  11. includeSystemClasspath=true
  12. logLevel=DEBUG
And I have next error. 
  1. >java -jar liquibase.jar diffChangeLog
  2. DEBUG 11.02.14 16:04:liquibase: Connected to sa@jdbc:jtds:sqlserver://localhost:1433/sample
  3. DEBUG 11.02.14 16:04:liquibase: Setting auto commit to false from true
  4. Liquibase diffChangeLog Failed: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to hibernate:spring:com.my.dao.entities with driver net.sourceforge.jtds.jdbc.Driver.  Possibly the wrong driver for the given database URL
  5. SEVERE 11.02.14 16:04:liquibase: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to hibernate:spring:com.my.dao.entities with driver net.sourceforge.jtds.jdbc.Driver.  Possibly the wrong driver for the given database URL
  6. liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to hibernate:spring:com.my.dao.entities with driver net.sourceforge.jtds.jdbc.Driver.  Possibly the wrong driver for the given database URL
  7.         at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:61)
  8.         at liquibase.integration.commandline.Main.createReferenceDatabaseFromCommandParams(Main.java:1005)
  9.         at liquibase.integration.commandline.Main.doMigration(Main.java:804)
  10.         at liquibase.integration.commandline.Main.main(Main.java:133)
  11. Caused by: liquibase.exception.DatabaseException: liquibase.exception.DatabaseException: Connection could not be created to hibernate:spring:com.my.dao.entities with driver net.sourceforge.jtds.jdbc.Driver.  Possibly the wrong driver for the given database URL
  12.         at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:231)
  13.         at liquibase.database.DatabaseFactory.openDatabase(DatabaseFactory.java:141)
  14.         at liquibase.integration.commandline.CommandLineUtils.createDatabaseObject(CommandLineUtils.java:52)
  15.         ... 3 more
  16. Caused by: liquibase.exception.DatabaseException: Connection could not be created to hibernate:spring:com.my.dao.entities with driver net.sourceforge.jtds.jdbc.Driver.  Possibly the wrong driver for the given database URL
  17.         at liquibase.database.DatabaseFactory.openConnection(DatabaseFactory.java:226)
  18.         ... 5 more

The same happent also for
  1. referenceDriver=com.microsoft.sqlserver.jdbc.SQLServerDriver
Does anybody have an idea?
Viewing all 2993 articles
Browse latest View live