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

Multiple Configurations in liquibase-maven-plugin

$
0
0
Hi together,

I am trying to configure the maven plugin (3.5.3) to run two different configurations on the same DB (but different user and different changelog).
My current code for a single configuration looks like this:

  1. <plugin>
    <groupId>org.liquibase</groupId>
    <artifactId>liquibase-maven-plugin</artifactId>
    <version>3.5.3</version>
    <configuration>
    <changeLogFile>
    ${basedir}/src/main/resources/db/changelog_1.xml
    </changeLogFile>
    <driver>oracle.jdbc.driver.OracleDriver</driver>
    <url>jdbc:oracle:thin:@localhost:1521:xe</url>
    <username>USER</username>
    <password>PASSWORD</password>
    </configuration>
    <dependencies>
    <dependency>
    <groupId>com.oracle</groupId>
    <artifactId>ojdbc7</artifactId>
    <version>12.1.0.2.0</version>
    </dependency>
    </dependencies>
    </plugin>
I read several times about executions with different configurations. But when I try to put a configuration inside an execution I get an error and liquibase won´t find it. The goal is to include a new configuration for "USER2" with "PASSWORD2" and "changelog_2.xml"
Any suggestions?

Thanks in advance :)


Re : Multiple Configurations in liquibase-maven-plugin

$
0
0
Can you post the two executions example so it can be verified?

Re : Multiple Configurations in liquibase-maven-plugin

$
0
0
Hi Daniel,

I wanted to do it like here http://stackoverflow.com/questions/4865767/liquibase-using-maven-with-two-databases

  1. <plugin>
        <groupId>org.liquibase</groupId>
        <artifactId>liquibase-maven-plugin</artifactId>
        <version>3.5.3</version>
        <executions>
            <execution>
                <id>id1</id>
                <phase>process-resources</phase>
                <configuration>
                    <changeLogFile>
                        ${basedir}/src/main/resources/db/changelog_1.xml
                    </changeLogFile>
                    <driver>oracle.jdbc.driver.OracleDriver</driver>
                    <url>jdbc:oracle:thin:@localhost:1521:xe</url>
                    <username>USER1</username>
                    <password>PASSWORD1</password>
                </configuration>
                <goals>
                    <goal>update</goal>
                </goals>
            </execution>
            <execution>
                <id>id2</id>
                <phase>process-resources</phase>
                <configuration>
                    <changeLogFile>
                        ${basedir}/src/main/resources/db/changelog_2.xml
                    </changeLogFile>
                    <driver>oracle.jdbc.driver.OracleDriver</driver>
                    <url>jdbc:oracle:thin:@localhost:1521:xe</url>
                    <username>USER2</username>
                    <password>PASSWORD2</password>
                </configuration>
                <goals>
                    <goal>update</goal>
                </goals>
            </execution>
        </executions>
        <dependencies>
            <dependency>
                <groupId>com.oracle</groupId>
                <artifactId>ojdbc7</artifactId>
                <version>12.1.0.2.0</version>
            </dependency>
        </dependencies>
    </plugin>

Re : ArrayIndexOutOfBoundsException on plpgsql anonymous blocks

$
0
0
As a workaround, using the "sql" change object instead of "sqlFile" gets me past the exception. But that's far from a perfect solution.

How can I create a bug report?

Re : ArrayIndexOutOfBoundsException on plpgsql anonymous blocks

Liquibase handling Default data and then adding data from hibernate in same table gives error

$
0
0
I am using liquibase to insert default user in database in admin table. I am using my web application (Spring boot, Hibernate ) to register new users. After populating database with default admin user, when i first try to add new user from web application in same admin table i get duplicate key value violates unique constraint Key already exists error


In my entity i have used GenerationType AUTO I have also tried with using SEQ and Table strategy but no fix.
How do i fix this issue so when a new user is added after default user added from liquibase it does not give you error

2 classpath questions

$
0
0
1.  I'm trying to use the teradata extension:  https://github.com/liquibase/liquibase-teradata/wiki

What is meant by "Simply add the liquibase-teradata.jar file to your classpath"?  The only way I have found that this works is by putting the jar in the `libexec/lib` directory.

Adding a relative or absolute path to the `--classpath` option does not result in it being found.

2.  The documentation makes it appear as though a directory should be possible in the `--classpath` argument, eg. `--classpath=\path\to\classes:jdbcdriver.jar`.

However, as an absolute or relative path, this always results in my JDBC driver not found.  Only a relative or absolute path to the jar itself works.

The documentation for URLClassLoader does not illuminate this subject for me, unfortunately.  Should a directory be possible here?






GenerateChangeLog Error with HANA database

$
0
0
Hi..
I am trying the 'GenerateChangeLog' option to the current SAP HANA Database.  

Properties File:
  driver: com.sap.db.jdbc.Driver
  classpath: D:\\liquibase-3.5.3-bin\\driver\\ngdbc.jar
  changeLogFile: D:\\Liquibase-3.5.3-bin\\xml_source\\HANAInstanceDef.xml
  url: jdbc:sap://localhost:30041/
  username: VIRTEST_SYS
  password: Password
  logLevel=DEBUG
  logFile=HANA_log.txt
  defaultSchemaName=VIRTEST_SYS
  defaultCatalogName=SYS


Execution:
>liquibase --defaultsFile="liquibase.properties" GenerateChangeLog

DEBUG 4/12/17 9:06 PM: liquibase: Connected to VIRTEST_SYS@jdbc:sap://localhost:30041
DEBUG 4/12/17 9:06 PM: liquibase: Setting auto commit to false from true
DEBUG 4/12/17 9:06 PM: liquibase: Computed checksum for 1492031201113 as 2b8096c98b7d9d0fbc76189789100efc
WARNING 4/12/17 9:06 PM: liquibase: Did not find catalog 'DEFAULT' to snapshot
SEVERE 4/12/17 9:06 PM: liquibase: liquibase.exception.DatabaseException: com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: [362] (at 57): invalid schema name: INFORMATION_SCHEMA: line 1 col 58 (at pos 57)
liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: liquibase.exception.DatabaseException: com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: [362] (at 57): invalid schema name: INFORMATION_SCHEMA: line 1 col 58 (at pos 57)
at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:265)
at liquibase.integration.commandline.Main.doMigration(Main.java:1011)
at liquibase.integration.commandline.Main.run(Main.java:188)
at liquibase.integration.commandline.Main.main(Main.java:103)
Caused by: liquibase.command.CommandExecutionException: liquibase.exception.DatabaseException: com.sap.db.jdbc.exceptions.JDBCDriverException: SAP DBTech JDBC: [362] (at 57): invalid schema name: INFORMATION_SCHEMA: line 1 col 58 (at pos 57)
at liquibase.command.AbstractCommand.execute(AbstractCommand.java:13)
at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:263)
... 3 more

-------------

I tried changing default schema and catalogs (as seen in the above properties file), but the error remains the same.  Any suggestions/guidance is much appreciated.

Thanks & Regards,
Virendra

Re : 2 classpath questions

$
0
0
How the classpath is constructed differs depending on how you are using Liquibase. Are you using the liquibase bat/shell scripts? From Windows or Linux? Are you using maven? Are you using something else? Each one has its own way of constructing the classpath. 

In general, most things do NOT allow for specifying a directory on the classpath. 

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

Re : 2 classpath questions

$
0
0
I was trying to use it with gradle, but my issue regarding the Teradata extension mentioned in my post prevented that from working at all, so this question is restricted to the shell.

Using liquibase if the Teradata extension has to be installed to `libexec/lib` will be a non-starter for me.  Should that worth with the `--classpath` argument?

Support for Liquibase extensions in offline mode

$
0
0
Hello All,

I'm trying to use maven + liquibase + mssql extension in offline to generate database scripts.

I have included the mssql extension jar file in the pom.xml.

But when I build, i do not see any changes related to isIdentityEnabled attribute.

Can you please suggest me on how to use the Liquibase extensions with Maven.

Thanks in advance.

Liquibase with EDB PostgreSQL

$
0
0

Hi All,

I'm doing a POC on Liquibase and EDB Postgresql. I'm getting following error when I try to deploy the changes 2nd time. I have to drop the log tables to continue deployment.

I enabled audit and found that Liquibase is trying to get the log table details and if not exists it is trying to create new tables.

In EDB postgres - tables are stored in LOWERCASE in metadata table - pg_class - where the Liquibase is checking for the log tables in UPPERCASE. I checked with EDB team , there is no configuration to change all tables to UPPERCASE..

Appreciate if you share any work around for this issue.

Here's the details-


liquibasedb=# select * from DATABASECHANGELOG;


id  |   author   |    filename    |      dateexecuted      | orderexecuted | exectype |               md5sum               | description | comments | tag | liquibase | contexts | labels | deployment_id


-----+------------+----------------+------------------------+---------------+----------+------------------------------------+-------------+----------+-----+-----------+----------+--------+---------------


raw | includeAll | changeset2.sql | 20-APR-17 06:04:07.836 |             1 | EXECUTED | 7:20ea501c3e0062fc5ef2047b7ec53890 | sql         |          |     | 3.5.3     |          |        | 2693447821


(1 row)


 


liquibasedb=# select * from pg_class where relname='DATABASECHANGELOG';


relname | relnamespace | reltype | reloftype | relowner | relam | relfilenode | reltablespace | relpages | reltuples | relallvisible | reltoastrelid | relhasindex | relisshared | relpersistence | relkind | relnatts | relchecks | relhasoids | relhaspkey | relhasrules | relhastriggers | relhassubclass | relrowsecurity | relforcerowsecurity | relispopulated | relreplident | relfrozenxid | relminmxid | relacl | reloptions


---------+--------------+---------+-----------+----------+-------+-------------+---------------+----------+-----------+---------------+---------------+-------------+-------------+----------------+---------+----------+-----------+------------+------------+-------------+----------------+----------------+----------------+---------------------+----------------+--------------+--------------+------------+--------+------------


(0 rows)


 


liquibasedb=# select * from pg_class where relname='databasechangelog';


      relname      | relnamespace | reltype | reloftype | relowner | relam | relfilenode | reltablespace | relpages | reltuples | relallvisible | reltoastrelid | relhasindex | relisshared | relpersistence | relkind | relnatts | relchecks | relhasoids | relhaspkey | relhasrules | relhastriggers | relhassubclass | relrowsecurity | relforcerowsecurity | relispopulated | relreplident | relfrozenxid | relminmxid | relacl | reloptions


-------------------+--------------+---------+-----------+----------+-------+-------------+---------------+----------+-----------+---------------+---------------+-------------+-------------+----------------+---------+----------+-----------+------------+------------+-------------+----------------+----------------+----------------+---------------------+----------------+--------------+--------------+------------+--------+------------


databasechangelog |         2200 |   16743 |         0 |       10 |     0 |       16741 |             0 |        0 |         0 |             0 |         16744 | f           | f           | p              | r       |       14 |         0 | f          | f          | f           | f              | f              | f              | f                   | t              | d            |         2039 |          1 |        |


(1 row)


 


How to do an alter session

$
0
0
Hi all,
There is a nice feature in Oracle Db called EBR (Edition Based Redefinition) but in order to use it I need to do for ex :

alter session set Edition=V1;

How to do that with liquibase before create stored function or stored procedure ?

Ty for help.

New Extension: Liquibase Snowflake support

Re : How to do an alter session

$
0
0
I did a changeset sqlfile

the migrate.sql file is nice...

-- *********************************************************************
-- Update Database Script
-- *********************************************************************
-- Change Log: src/main/resources/db/v1/master.xml
-- Ran at: 26/04/17 11:51
-- Against: QUIZLIQUIBASE@jdbc:oracle:thin:@localhost:1521/pdb1
-- Liquibase version: 3.5.3
-- *********************************************************************

SET DEFINE OFF;

-- Lock Database
UPDATE DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = 'CHPRUVOS-FR (192.168.28.1)', LOCKGRANTED = to_timestamp('2017-04-26 11:51:43.333', 'YYYY-MM-DD HH24:MI:SS.FF') WHERE ID = 1 AND LOCKED = 0;

-- Changeset src/main/resources/db/v1/06-03-2017-1.xml::editionview1::cp
ALTER SESSION SET EDITION=V1;

....

But the result is NOK

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.5.3:update (default-cli) on project quizdbliqui: Error setting up or running Liquibase: Migration failed for change set src/main/resources/db/v1/06-03-2017-1.xml::editionview1::cp:
[ERROR] Reason: liquibase.exception.DatabaseException: ORA-00922: option erronée ou absente
[ERROR] [Failed SQL: ALTER SESSION SET EDITION=V1;]


How to Create Procedure on HANA database through Liquibase

$
0
0
Hi 
Currently I am trying to create procedure on HANA database, but does not quite working, it is able to insert record into databasechangelog and does not show any error during the execution, however, it does not create the procedure in specified schema.  I will appreciate any response in the matter.  Thank you!


XML File:
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
 <changeSet author="oracle (generated)" id="1491933527660-2002">
    <createProcedure catalogName="sys"
dbms="hana"
            encoding="utf8"
            procedureName="TESTHANA"
            relativeToChangelogFile="true"
            schemaName="LB_TEST">create procedure TESTHANA () language SQLSCRIPT
AS
BEGIN
select 1 from dummy;
END;
</createProcedure>
</changeSet>
</databaseChangeLog>

Re : Looking for feedback on cross-database support

$
0
0
Hi Nathan,

I can share my recent experience for using changlog file generated from Oracle and used it for HANA database, the following adjustments I had to make to use the same changlog successfullly,  in the end they seem minor changes and worth time spent as the changes applied to HANA went as expected.

Tables :
- removed default value "sysdate" from the column definition
- changed data type: binary_double to double
- changed data type: Long raw to blob

DATA file :
- No change required, all data loads successfully including CLOB fields

Sequences:
Sequence creation worked after removing clauses : cache and order

Primary key constraints:
Removed the following pattern as HANA does not create physical index for primary key
- <createIndex.*?/createIndex>
- forIndexName.*?PK1"

Unique key constraints:
Removed the following pattern as HANA does not create physical index for unique key
- <createIndex.*?/createIndex>
- forIndexName.*?UK1"
     
Foreign Key constraints:
- corrected datatype from CHAR to VARCHAR  (HANA does not support constraints on CHAR columns)
   
Indexes
- corrected the following line as HANA does not support "SYS_OP_C2C"
<column computed="true" name="SYS_OP_C2C(<COLUMN_NAME>)"/>  

In addition to above, we do have few procedures to be created on HANA.   Since they are less, i have created xml files to be loaded into HANA, however, did not succeed so far as "dbms=hana" does not seem to work well with HANA and procedure is not able to be created.   

Let me know if you need more information.

Thanks & regards,
Viren

Re : Looking for feedback on cross-database support

$
0
0
We manage changelogs that are targeted against Oracle and Postgres and sometimes SQL Server. 

One thing that we had to take care of is Oracle's "char semantic". In order to ensure that VARCHAR(30) is indeed created as VARCHAR(30 Char) in Oracle we put the following at the start of each changelog:

  1.     <changeSet author="dba" id="char_semantics" dbms="oracle" runAlways="true">
            <sql>alter session set nls_length_semantics = 'CHAR'</sql>
        </changeSet>

Another thing that we do is to use properties e.g. to define columns for UUIDs:


  1.   <property name="uuid_function" value="uid.uuid_generate_v4()" dbms="postgresql"/>
      <property name="uuid_function" value="NEWID()" dbms="mssql"/>
      <property name="uuid_function" value="sys_guid()" dbms="oracle"/>

      <property name="uuid_type" value="uuid" dbms="postgresql"/>
      <property name="uuid_type" value="uniqueidentifier" dbms="mssql"/>
      <property name="uuid_type" value="RAW(32)" dbms="oracle"/>
     
      <changeSet author="arthur" id="1">
        <createTable tableName="foo">
          <column name="id" type="${uuid_type}" defaultValueComputed="${uuid_function}">
            <constraints nullable="false" />
          </column>
        </createTable>
      </changeSet>

The rules when Liquibase quotes object names are also not helpful. Consider e.g. the following:

    <createTable tableName="FooBar">

For Oracle Liquibase does not quote the table name and creates a table named FOOBAR. For Postgres Liquibase quotes the table name and thus a table with a quoted identifier is created "FooBar". For SQL Server the name is also not quoted. We finally created our own implementation of PostgresDatabase that only quotes names if they contain special characters or if they are reserved words. If you are interested, I am willing to share this implementation. I have seen some questions on Stackoverflow regarding this as well, so we are not the only ones.

Not really a DBMS topic, but: we run changelogs from the commandline and through Maven alike (depending on the developer and the environment). In that case the "current directory" is different which means that Liquibase will put a different value into the column "filename" of the databasechangelog table. Which in turn means that a second run of the changelog in a different environment will fail because the filename is part of the primary key of that table and Liquibase doesn't consider the changeSets as executed.

We wind up using "logicalFilePath" in all our changeLogs that only contains the filename, not the path and thus always uses the same value regardless of the environment. That however is error prone as it requires manual steps when creating new changelogs.

From my perspective, this (use the file name, not the full path) should be the default behavior of Liquibase.

Re : Liquibase handling Default data and then adding data from hibernate in same table gives error

$
0
0
Hello, if i understand,

1 - you added a new user in admin table by a changeset that ran.
2 - After this, you tried to add a new user via your web application in the same table.

At my first read, it seems to be an error in your code.
The error is explicit : You tried to insert a user with a unique id already existing in your table.

- Verify that the PRIMARY_KEY (admin.ID or admin.ADMIN_ID or the column name you chose) has AUTO_INCREMENT setted.
- Verify that you didn't set an ID explicitly in your DAO query which inserts a new user and your changeset that creates the default user. Normally it is automatically generated by mysql.
With AUTO_INCREMENT you don't need to specify explicitly this column and value in your insert query.

- Verify the annotation or strategy generation of your id attribute in your entity Admin :
@Id @GeneratedValue(strategy=GenerationType.AUTO)
or
@Id @GeneratedValue(strategy=GenerationType.IDENTITY)

Hoping that it helped you.
Regards

Re : Multiple Configurations in liquibase-maven-plugin

$
0
0
An alternative is to use a properties file in <configuration>...</configuration> and define one profile for each database configuration to apply it at the plugin's execution.

So you can select the profile corresponding to the db and the changelog associated at the execution of the plugin.

Send me your full configuration of pom.xml by PV if you are interested by this alternative because i haven't the time at this moment to post the few steps.

Regards
Viewing all 1169 articles
Browse latest View live


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