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

Re : CustomtaskChange passing a parameter

$
0
0
Hi Daniel

Just tried the command and it is not working,


  1. public class TableSiteGUID implements liquibase.change.custom.CustomTaskChange {
  2.     private String table;
  3.     public void SetTableName(String table) {
  4.         this.table = table;
  5.     }




  1.     <changeSet author="me" id="add suppliers primarykey (MS)" >
  2.         <customChange class="uk.jdl.pos.util.TableSiteGUID" >          
  3.             <param name="SetTableName" value="tests"/>
  4.         </customChange>
  5.     </changeSet>



it seems to fail when it tries to run the param setting, with out that the class will execute.

John



Change to primaryKeyExists precondition

$
0
0
In liquibase 3.4.2, this worked:

- changeSet:
    id: 1450270295661-5
    author: blah
    preConditions:
        onFail: MARK_RAN
        not:
            primaryKeyExists:
                primaryKeyName: data_pkey
    changes:
    - addPrimaryKey:
        columnNames: id, type
        constraintName: data_pkey
        tableName: data

In liquibase 3.5.3, it must look like this:
- changeSet:
    id: 1450270295661-5
    author: blah
    preConditions:
        onFail: MARK_RAN
        not:
            primaryKeyExists:
                primaryKeyName: data_pkey
                tableName: data
    changes:
    - addPrimaryKey:
        columnNames: id, type
        constraintName: data_pkey
        tableName: data

Or I get an exception:  liquibase.exception.DatabaseException: java.sql.SQLException: Invalid argument in JDBC call: table: null

The change is easy enough to make, but a change to a changeset changes the checksum, which will break all future releases of my product, right? Is there some workaround to this?

Possible to run tasks from Java?

$
0
0
I'm wondering if it's possible to just run tasks such as these directly from Java using classes instead of having to utilize ANT, Commandline or something else?

dbDoc
generateChangeLog
update

Re : Possible to run tasks from Java?

$
0
0
Yes, this is totally possible. That is what we have done at Datical - we have written an Eclipse-RCP based GUI as well as an Eclipse command line that wrap and extend Liquibase. You can get some idea of how that would work by looking at the open source implementations of the existing integrations. One of the easiest to understand, in my opinion, is the command line integration. 

This package is where I would suggest you start:

Line 1143 in Main is where the update command is processed. There is some command-line processing of course, but that is a good place to start looking. 

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

Re : Possible to run tasks from Java?

$
0
0
Thank you for the assist, I'll take a look in that location.

How to configure alternate liquibase control tables (DATABASECHANGELOG & DATABASECHANGELOGLOCK)

$
0
0
Following the inputs from the below forum, system properties were specified and customized names for DATABASECHANGELOG & DATABASECHANGELOGLOCK tables were used & setup (on liquibase update execution).

But, on subsequent attempts to execute future liquibase updates (against same Oracle database schema), the execution fails as its trying to recreate the customized DATABASECHANGELOG table again - failing with liquibase: ORA-00955: name is already used by an existing object

Environment details:
  • Liquibase 3.5.1
  • Oracle 12c
  • JDK 8
  • OS - Redhat Linux 64-bit

This does not happen when trying to use the standard liquibase control tables names (i.e. DATABASECHANGELOG & DATABASECHANGELOGLOCK). 

Also, tested the same scenario against a PostGres 9.5 database, and configured liquibase control tables work as expected (similar to standard control tables).

Any suggestions to fix this?

How to generate xml file from databaseChangeLog object

$
0
0
Any tips how to generate the xml file based on a databaseChangeLog object from java.

Re : How to generate xml file from databaseChangeLog object


Rollback multiple Update

$
0
0

We are running liquibase version 3.5 with Oracle. We are unable to perform rollbacks in liquibase ,against multiple update/insert operation in a single changesets.

 

Scenario is that we have list of multiple updates DMLs in a change-set that will update different tables when running liquibase command. But we did not yet conclude how to Perform Rollback in simple way.

Do we have to write a rollback query for each update command. If yes that’s mean if we have 100 updates so we have to write 100 Rollback queries against each Update statement.

 

Is there any solution or use case that we can follow and rollback using a single statement.


e.g. update Table set xyz='someValue' where ID=102;


so i want a rollback, please suggest i have 100 of queries like above

[Spring Boot + JPA/Hibernate + Liquibase Core dependency] Can Liquibase track changes done on Entity classes?

$
0
0
Can Liquibase track changes done on Entity classes, that is, if I add a column to an entity class - can Liquibase generate a changeset and apply it to my database?

If yes, can you please provide some info on how to proceed. If it's appropriate to leave Stackoverflow links here, I can post a link to a question I wrote today.

How to generate rename column instead of drop column

$
0
0
Hi there,

I'm new with Liquibase. I have researched on that case but still stuck.
Environment
+ Database: PostgreSQL 9.6 on Ubuntu 
+ SOURCE
  1. table t1 ( ab int, b int) -- 0 row
  2. table t2 ( a int , b int) -- 0 row
+ TARGET
  1. table t1 (a int, b int) -- 2 row
  2. table t2 (a int, b int) -- 0 row

Then I use command below to compare source verse target
  1. ./run-liqb --driver=org.postgresql.Driver \
  2. --classpath=./lib/postgresql-42.0.0.jar \
  3. --url=jdbc:postgresql://localhost:5432/target \
  4. --username=postgres \
  5. --password=123456 \
  6. diffChangeLog \
  7. --referenceUrl=jdbc:postgresql://localhost:5432/source \
  8. --referenceUsername=postgres \
  9. --referencePassword=123456 >> dif.changelog.xml

The content of dif.changelog.xml is:
  1. <?xml version="1.1" encoding="UTF-8" standalone="no"?>
  2. <databaseChangeLog...............>
  3.     <changeSet author="sentifi (generated)" id="1490856133794-1">
  4.         <createTable tableName="t3">
  5.             <column name="a" type="INT"/>
  6.             <column name="b" type="INT"/>
  7.         </createTable>
  8.     </changeSet>
  9.     <changeSet author="sentifi (generated)" id="1490856133794-2">
  10.         <addColumn tableName="t1">
  11.             <column name="ab" type="int4"/>
  12.         </addColumn>
  13.     </changeSet>
  14.     <changeSet author="sentifi (generated)" id="1490856133794-3">
  15.         <dropColumn columnName="a" tableName="t1"/>
  16.     </changeSet>
  17. </databaseChangeLog>

Actually, I don't want to drop column t1.a on target. 
Of course, I can it manually but I hope other ways. Are there other way to work around ? 

Please ask me if you need more detailed info.

Thank you.




Re : How to generate rename column instead of drop column

$
0
0
Hu Luan,

this is exactly the reason why automatic change management does not work. I've never seen a tool that is able to distinguish a rename vs. drop and add (works for columns or for tables). This decision can only be made by a real person having extra knowledge about the system using the datamodel and if you provide that context to a tool you are half way of doing it right yourself.

kind regards
Daniel

Re : How to configure alternate liquibase control tables (DATABASECHANGELOG & DATABASECHANGELOGLOCK)

$
0
0
Did you check permissions? Maybe you are using a different user that does not see the table but it s already there.
Or are there any synonyms around, that may be a problem too?

Re : Rollback multiple Update

$
0
0
I don't think that this is possible to do automatically.

First and foremost if you think of a generic rollback there needs to be information about the old state of the data you manipulated with the query. I your case it seems you changed one record with a given ID, but liquibase does not know the old value of your table, so no way to roll it back automatically. It gets even worse if you update multiple records with one statement, then there may be multiple values (each different in every record you update).

That is not possible to rollback automatically if you do not have a custom backup mechanism you may implement a semi automatic rollback, but this mechanic is not provided by liquibase.

What you can do is implement your own custom update/delete statement that does not only change a record but back it up for possible rollbacks and implement the rollback for that change too.

kind regards

Re : How to generate rename column instead of drop column

$
0
0
Hi Danial,

Thank you.
It means we cannot use rename column automatically. Of course, I think it's hard for Liquibase to know when it should drop or add or rename a table/column. 

Oracle Wallet

$
0
0
I have finally been able to make liquibase aware of oracle wallet. I am running Oracle 11.2. The whole command is in one line,but I am showing it in multiple lines for clarity:

 mvn -X -e liquibase:update
-Dliquibase.emptyPassword=false (I have tried true no luck)
-Dliquibase.username=USER
-Dliquibase.url=jdbc:oracle:thin:/@oracle1
-Ddriver=oracle.jdbc.OracleDriver
-Doracle.net.tns_admin=/apps01/oracle/client/network/admin
-Doracle.net.wallet_location=/apps01/oracle/wallet
-Dliquibase.changelogSchemaName=USER
-Dliquibase.changelogCatalogName=USER
-Dliquibase.contexts=oracle1,my-ticket

Caused by: java.sql.SQLException: ORA-01005: null password given; logon denied

.I am passing all arguments in the command instead of using the liquibase.properties file.

Why is liquibase not picking up the password for USER ?
Yes the entries for tnsname.ora, sqlnet.ora, wallet.ora are all correct, since when I type "sqlplus /@oracle1" it works

$ sqlplus /@oracle1

SQL*Plus: Release 11.2.0.1.0 Production on Fri Mar 31 14:40:25 2017

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL>


Any clues? Pointers?

Re : How to configure alternate liquibase control tables (DATABASECHANGELOG & DATABASECHANGELOGLOCK)

$
0
0
Thanks Daniel. 

I stumbled upon a solution and I believe its an oracle-specific issue. When connected with Oracle database, the configured table names specified SHOULD be in ALL CAPS for it to be consistently recognized across multiple liquibase runs (first time setup & subsequent attempts to migrate). 

As mentioned earlier, when running similar scenario against postgres database - the configured liquibase control table names are not case sensative, i.e., it works appropriately across multiple liquibase runs even when the table names are specified is in small case.

Since Liquibase uses JDBC connectivity to perform its operations using the database-specific driver - I assume its safe to attribute this behavior to ojdbc7.jar (oracle driver I specified in the classpath when performing liquibase operations against Oracle database).

Re : Configurable DATABASECHANGELOG table name ?

$
0
0
Thanks Gavriel - your example was super helpful to get me going.

I hit this weird issue when attempting to configure liquibase control tables against an Oracle database (in first run control tables were created as expected, but on subsequent attempts to migrate the schema the control tables were attempted to be recreated resulting in errors). 

Posting the solution I stumbled upon, it may be useful for someone (IMO its an oracle-specific issue):

Against Oracle Database:
The configured liquibase control table names SHOULD be specified in ALL CAPS for it to be consistently recognized across multiple liquibase runs (first time setup & subsequent attempts to migrate). 

Against Postgres Database:
The configured liquibase control table names are not required to be in ALL CAPS, i.e., it works appropriately across multiple liquibase runs even when the table names are specified is in small case.

As Liquibase uses JDBC connectivity to perform its operations using the database-specific driver - I assume its safe to attribute this behavior to ojdbc7.jar (oracle driver I specified in the classpath when performing liquibase operations against Oracle database).

Liquibase does not create indexed view for an empty database

$
0
0
CREATE TABLE dbo.testTable
(
ID nchar(10) NOT NULL,
TestDate datetime2(3) NULL
)
go

ALTER TABLE dbo.testTable ADD CONSTRAINT
PK_testTable PRIMARY KEY( ID)
GO

CREATE VIEW dbo.vw_test
WITH SCHEMABINDING
AS
SELECT TestDate, COUNT(1) AS Expr1
FROM dbo.testTable
GROUP BY TestDate
GO

CREATE UNIQUE CLUSTERED INDEX IX_Test_TestDate
ON vw_test (TestDate);
GO

Liquibase with version 3.4.1 somehow drops the with option and does not create the indexed view. It gives the sql error when trying to create unique clustered index. Is there any solution or work around for this?

ArrayIndexOutOfBoundsException on plpgsql anonymous blocks

$
0
0
Is there a trick to executing anonymous plpgsql blocks in Liquibase?

I have the following YAML file:

  1. databaseChangeLog:
      - changeSet:
          id: dcrews:1
          runOnChange: true
          runInTransaction: true
          splitStatements: false
          endDelimiter: $$;
          changes:
          - sqlFile:
              path: anonymous_plpgsql.sql
              relativeToChangelogFile: true
              schemaName: sms

which references this do-nothing block in "anonymous_plpgsql.sql":

  1. DO
    $$
    BEGIN
            RAISE NOTICE 'Hello, world.';
    END
    $$;

It runs fine in my PostgreSQL client, but in Liquibase I always get an ArrayIndexOutOfBoundsException:


DEBUG 4/4/17 6:42 PM: liquibase: Connected to [redacted]
DEBUG 4/4/17 6:42 PM: liquibase: Setting auto commit to false from true
DEBUG 4/4/17 6:42 PM: liquibase: Executing QUERY database command: select count(*) from sms.databasechangeloglock
DEBUG 4/4/17 6:42 PM: liquibase: Executing QUERY database command: select count(*) from sms.databasechangeloglock
DEBUG 4/4/17 6:42 PM: liquibase: Executing QUERY database command: SELECT LOCKED FROM sms.databasechangeloglock WHERE ID=1
DEBUG 4/4/17 6:42 PM: liquibase: Lock Database
DEBUG 4/4/17 6:42 PM: liquibase: Executing UPDATE database command: UPDATE sms.databasechangeloglock SET LOCKED = TRUE, LOCKEDBY = '10.64.21.111 (10.64.21.111)', LOCKGRANTED = '2017-04-04 18:42:10.909' WHERE ID = 1 AND LOCKED = FALSE
INFO 4/4/17 6:42 PM: liquibase: Successfully acquired change log lock
DEBUG 4/4/17 6:42 PM: liquibase: Computed checksum for 1491331332477 as eb0dd71e9c2405de3d87f993a981f08a
DEBUG 4/4/17 6:42 PM: liquibase: Executing QUERY database command: SELECT MD5SUM FROM sms.databasechangelog WHERE MD5SUM IS NOT NULL LIMIT 1
DEBUG 4/4/17 6:42 PM: liquibase: Executing QUERY database command: select count(*) from sms.databasechangelog
INFO 4/4/17 6:42 PM: liquibase: Reading from sms.databasechangelog
DEBUG 4/4/17 6:42 PM: liquibase: Executing QUERY database command: SELECT * FROM sms.databasechangelog ORDER BY DATEEXECUTED ASC, ORDEREXECUTED ASC
DEBUG 4/4/17 6:42 PM: liquibase: ArrayIndexOutOfBoundsException.yaml: ArrayIndexOutOfBoundsException.yaml::dcrews:1::null: Computed checksum for inputStream as f628dad39e0ef7b15ec039f91d8289c0
DEBUG 4/4/17 6:42 PM: liquibase: ArrayIndexOutOfBoundsException.yaml: ArrayIndexOutOfBoundsException.yaml::dcrews:1::null: Computed checksum for 7:f628dad39e0ef7b15ec039f91d8289c0: as 121c4496138fa4845aca91735d100959
DEBUG 4/4/17 6:42 PM: liquibase: ArrayIndexOutOfBoundsException.yaml: ArrayIndexOutOfBoundsException.yaml::dcrews:1::null: Running Changeset:ArrayIndexOutOfBoundsException.yaml::dcrews:1::null
DEBUG 4/4/17 6:42 PM: liquibase: ArrayIndexOutOfBoundsException.yaml: ArrayIndexOutOfBoundsException.yaml::dcrews:1::null: Changeset ArrayIndexOutOfBoundsException.yaml::dcrews:1::null
DEBUG 4/4/17 6:42 PM: liquibase: ArrayIndexOutOfBoundsException.yaml: ArrayIndexOutOfBoundsException.yaml::dcrews:1::null: Reading ChangeSet: ArrayIndexOutOfBoundsException.yaml::dcrews:1::null
SEVERE 4/4/17 6:42 PM: liquibase: ArrayIndexOutOfBoundsException.yaml: ArrayIndexOutOfBoundsException.yaml::dcrews:1::null: Change Set ArrayIndexOutOfBoundsException.yaml::dcrews:1::null failed.  Error: null
DEBUG 4/4/17 6:42 PM: liquibase: ArrayIndexOutOfBoundsException.yaml::dcrews:1::null: Release Database Lock
DEBUG 4/4/17 6:42 PM: liquibase: ArrayIndexOutOfBoundsException.yaml::dcrews:1::null: Executing UPDATE database command: UPDATE sms.databasechangeloglock SET LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1
INFO 4/4/17 6:42 PM: liquibase: ArrayIndexOutOfBoundsException.yaml::dcrews:1::null: Successfully released change log lock
Unexpected error running Liquibase: Unknown Reason

SEVERE 4/4/17 6:42 PM: liquibase: ArrayIndexOutOfBoundsException.yaml::dcrews:1::null: Unknown Reason
liquibase.exception.MigrationFailedException: Migration failed for change set ArrayIndexOutOfBoundsException.yaml::dcrews:1::null:
     Reason: java.lang.ArrayIndexOutOfBoundsException
        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:605)
        at liquibase.changelog.visitor.UpdateVisitor.visit(UpdateVisitor.java:51)
        at liquibase.changelog.ChangeLogIterator.run(ChangeLogIterator.java:79)
        at liquibase.Liquibase.update(Liquibase.java:214)
        at liquibase.Liquibase.update(Liquibase.java:192)
        at liquibase.integration.commandline.Main.doMigration(Main.java:1126)
        at liquibase.integration.commandline.Main.run(Main.java:184)
        at liquibase.integration.commandline.Main.main(Main.java:103)
Caused by: java.lang.ArrayIndexOutOfBoundsException
        at java.lang.System.arraycopy(Native Method)
        at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:536)
        at java.lang.StringBuilder.append(StringBuilder.java:204)
        at org.postgresql.core.Parser.parseSql(Parser.java:1020)
        at org.postgresql.core.Parser.replaceProcessing(Parser.java:974)
        at org.postgresql.core.CachedQueryCreateAction.create(CachedQueryCreateAction.java:42)
        at org.postgresql.core.QueryExecutorBase.createQueryByKey(QueryExecutorBase.java:304)
        at org.postgresql.core.QueryExecutorBase.createQuery(QueryExecutorBase.java:315)
        at org.postgresql.jdbc.PgConnection.nativeSQL(PgConnection.java:706)
        at liquibase.database.jvm.JdbcConnection.nativeSQL(JdbcConnection.java:236)
        at liquibase.change.AbstractSQLChange.generateStatements(AbstractSQLChange.java:216)
        at liquibase.database.AbstractJdbcDatabase.executeStatements(AbstractJdbcDatabase.java:1253)
        at liquibase.changelog.ChangeSet.execute(ChangeSet.java:568)
        ... 7 more


For more information, use the --logLevel flag
 

It's not related to the RAISE NOTICE command, but seems to be any code within a plpgsql anonymous block.

The database is PostgreSQL 9.6.1, but the problems appears on 9.4.7 as well.

Viewing all 1169 articles
Browse latest View live


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