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

Generate SQL file in liquibase offline mode

$
0
0
I want to generate a SQL file from which I can generate my database. It works when I connect to the database but I want to do in offline mode. So I try this via command line:

 .\liquibase --url=offline:mysql? `
--driver=org.mariadb.jdbc.Driver `
--classpath=C:/Users/Ferid/Downloads/mariadb-java-client-2.2.4.jar `
--changeLogFile=C:/Users/Ferid/Downloads/liquibase-3.5.5-bin/sdk/workspace/changelog/com/example/changelogTestCust.xml `
--outputFile=C:/Users/Ferid/Downloads/liquibase-3.5.5-bin/new2 `
updatesql

When I do this it just generates a file like this:

--  *********************************************************************
--  Update Database Script
--  *********************************************************************
--  Change Log: C:/Users/Ferid/Downloads/liquibase-3.5.5-bin/sdk/workspace/changelog/com/example/changelogTestCust.xml
--  Ran at: 5/30/18 3:36 PM
--  Against: null@offline:mysql?
--  Liquibase version: 3.5.4
--  *********************************************************************

This only happens when I try to generate it in offline mode so what am I doing wrong? I have tried it with offline mode for MySQL, Oracle and MSSQL and all give me this result.

Upgrade from 3.4.2 to 3.5.5 includeAll issues

$
0
0
Hello,
We are using liquibase in dev and production enviorments and right now we tried to upgrade from 3.4.2 to 3.5.5. The big game breaking issue that we hit on is that for some reason when starting to boot up our app using spring, the liquibase bean fails to find the xml.files from a folder specified with the "includeAll" tag.
The error that we receive is "liquibase.exception.ChangeLogParseException: liquibase.exception.SetupException: Could not find directory or directory was empty for includeAll"

Anybody got any hints on this?

Are using contexts a best practice for revertible drop using a rename

$
0
0
Hello!

I'm trying to make my liquibase changesets in a manner that gives an opportunity to rollback, even when the final intent of my action is to drop data.The idea being that the first time I run it, i give it the "SAFE" context, which, by default, runs anything without a context, and, a week later, I run it with the "DROP" context, when I'm ready to commit to losing the data. In this effort, I've started doing this:
  1. <changeSet id="schema-drop-from-table-0006-rename" author="author">
  2.     <renameColumn tableName="TABLE1" oldColumnName="COL1" newColumnName="COL1_DROP_ME" />
  3. </changeSet>
  4.     <changeSet id="schema-drop-from-table-0006-drop" author="author" context="DROP">
  5.     <dropColumn tableName="TABLE1" columnName="COL1_DROP_ME" />
  6. </changeSet>
Is anyone else doing this? Any comments on this technique?

How to set extension for a liquibase installed on CentOS?

$
0
0
Hi All,

I have liquibase installed on CentOS, but I have got very old scripts created for version 1.9, so, they need modifyColumn tag to run.

I found that there is an extension for liquibase version 3.1 and elder which can add this functionality.


But I cannot figure out how to install this extension to my liquibase.
On my CetOS it is intalled as a jar file, so I cant put the extension jar to it.

When I put this jar as a set_classpath value it does not work.

Could you help me with this problem?

How to run a hardcore sqlfile from liquibase? Getting errors no matter what I do.

$
0
0
I have a file with the contents like below.   I get get anything to run and I would like to take these scripts that my team is used to developing and run them from <sqlfile>  tags. I have never had major issues like this file is presenting to me.  Basically no matter what I strip out nothing runs.  I have never faced anything like this before but I admit these scripts are different than what I am used to.   They do seem to execute via plsql dev so I don't think they are very broken or anything.   I am confused, tired, and have tried everything.   I am hoping someone sees an obvious issue here.

-----------------Error is this ------------------------

java -jar liquibase.jar --changeLogFile=master.xml update

Unexpected error running Liquibase: ORA-00900: invalid SQL statement
 [Failed SQL: spool preSQL_66_1_BKERINSF_Backup.out
alter session set current_Schema=BKERINSF]

------------------------------------Change set is this---------------------------------

<changeSet author="James" id="99900bk2323">
      <sqlFile dbms="oracle"
            encoding="utf8"
            endDelimiter=";"
            path="SQL/preSQL_99900_bkerinsf_backup.sql"
            relativeToChangelogFile="true"
            splitStatements="true"
            stripComments="true"/>
 </changeSet>

-------------------------File contents are as follows ----------------------
alter session set current_Schema=BKERINSF;set serveroutput on size 1000000;set echo on time on timing on/* ALTER SESSION enable parallel ddl; */ALTER SESSION force parallel ddl parallel 8;BEGIN  EXECUTE IMMEDIATE 'DROP TABLE BKP_BK_STG_NSF_L1_SR_KYINT' ;    EXCEPTION      WHEN OTHERS THEN 	    NULL;END;/
alter session set current_Schema=BKERINSF;set serveroutput on size 1000000;set echo on time on timing on/* ALTER SESSION enable parallel ddl; */ALTER SESSION force parallel ddl parallel 8;BEGIN  EXECUTE IMMEDIATE 'DROP TABLE BKP_BK_ST2_ERIC_NSF_PD_VAL' ;    EXCEPTION      WHEN OTHERS THEN NULL;END;BEGIN  EXECUTE IMMEDIATE 'DROP TABLE BKP_BK_STG_ERIC_NSF_PD_VAL' ;    EXCEPTION      WHEN OTHERS THEN NULL;END;BEGIN  EXECUTE IMMEDIATE 'DROP TABLE BKP_BK_ST2_ERIC_NSF_SFA' ;    EXCEPTION      WHEN OTHERS THEN NULL;END;BEGIN  EXECUTE IMMEDIATE 'DROP TABLE BKP_BK_STG_ERIC_NSF_SFA' ;    EXCEPTION      WHEN OTHERS THEN NULL;END;/BEGIN    EXECUTE IMMEDIATE 'CREATE TABLE BKP_BK_ST2_ERIC_NSF_PD_VAL COMPRESS FOR ALL OPERATIONS AS SELECT /*+ parallel(BK_ST2_NSF_PD_VAL) */ * FROM BK_ST2_NSF_PD_VAL';  EXECUTE IMMEDIATE 'ALTER TABLE BKP_BK_ST2_ERIC_NSF_PD_VAL PARALLEL 1'; 	  EXECUTE IMMEDIATE 'CREATE TABLE BKP_BK_STG_ERIC_NSF_PD_VAL COMPRESS FOR ALL OPERATIONS AS SELECT /*+ parallel(BK_STG_NSF_PD_VAL) */ * FROM BK_STG_NSF_PD_VAL';  EXECUTE IMMEDIATE 'ALTER TABLE BKP_BK_STG_ERIC_NSF_PD_VAL PARALLEL 1'; 	  EXECUTE IMMEDIATE 'CREATE TABLE BKP_BK_ST2_ERIC_NSF_SFA COMPRESS FOR ALL OPERATIONS AS SELECT /*+ parallel(BK_ST2_NSF_SFA) */ * FROM BK_ST2_NSF_SFA';  EXECUTE IMMEDIATE 'ALTER TABLE BKP_BK_ST2_ERIC_NSF_SFA PARALLEL 1';   EXECUTE IMMEDIATE 'CREATE TABLE BKP_BK_STG_ERIC_NSF_SFA COMPRESS FOR ALL OPERATIONS AS SELECT /*+ parallel(BK_STG_NSF_SFA) */ * FROM BK_STG_NSF_SFA';  EXECUTE IMMEDIATE 'ALTER TABLE BKP_BK_STG_ERIC_NSF_SFA PARALLEL 1';   EXCEPTION     WHEN OTHERS THEN 	      dbms_output.put_line(SQLCODE || '  ' || SQLERRM); END;/ALTER SESSION enable parallel dml;declaretbl_cnt number;bkp_tbl_cnt number;BEGIN  FOR i IN  (SELECT        'select count(1) FROM '||TABLE_NAME BKP_TBL,           table_name tabname   FROM ALL_TABLES   WHERE OWNER = 'BKERINSF'    AND TABLE_NAME IN ('BKP_BK_ST2_ERIC_NSF_PD_VAL','BKP_BK_STG_ERIC_NSF_PD_VAL','BKP_BK_ST2_ERIC_NSF_SFA','BKP_BK_STG_ERIC_NSF_SFA')  )  LOOP  EXECUTE immediate i.BKP_TBL into bkp_tbl_cnt;  dbms_output.put_line('Backup Table '||i.tabname||' - record cnt: '||to_char(bkp_tbl_cnt,'999,999,999,999'));  END LOOP;END;/

Re : How to set extension for a liquibase installed on CentOS?

$
0
0
May be the problem is that we are trying to use version 3.1... I will upgrade it to 3.2.3 and try to do everything once again 

DB2 precition issue.

$
0
0
DB2 only allows maximum 31 precision for a Decimal( eg. numeric(31,3)) thus when we have something like numeric(38,3) it will fail and liquibase will throw exception. I am wondering if there is a way in liquibase to cap the precision to 31 in its rendering to DB2?

Re : DB2 precition issue.

$
0
0
None that I know of. You would need to do something like what Datical does and pre-process the changelog. Datical implements a forecast tool that simulates operations, and also has a rules engine that allows for very detailed checks. 

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

Anyone ever used it with UCanAccess

$
0
0
Hi all,

I just discovered liquibase and wanted to test it with an Access database. It seems it can load everything ok, but then I get the following when trying to run a diff:
  1. liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: liquibase.exception.DatabaseException: net.ucanaccess.j
    dbc.UcanaccessSQLException: UCAExc:::4.0.4 user lacks privilege or object not found: CONSTRAINTS
            at liquibase.integration.commandline.CommandLineUtils.doDiff(CommandLineUtils.java:201)
ucanaccess url props include ;showSchema=true;sysSchema=true

Otherwise, I can work with this database via ucanaccess just fine. Any ideas?

Thanks,
Armin

Re : How to set extension for a liquibase installed on CentOS?

$
0
0
Yes, upgrade has solved the problem.

comments not added to "comments" column in DATABASECHANGELOG table

$
0
0
Hi,

I am trying to add comments to my changesets but even though it creates comments inside SQL statements as well as in the update database scripts it doesn't seem to be able to add that to the DATABASECHANGELOG table. Isn't that the expected behaviour?

on a related note, in the documentation there is this example:

<changeSet author="liquibase-docs" id="sql-example">
    <sql dbms="h2, oracle"
            endDelimiter="\nGO"
            splitStatements="true"
            stripComments="true">insert into person (name) values ('Bob')
        <comment>What about Bob?</comment>
    </sql>
</changeSet>
That doesn't work as advertised.
You have to put the <comment> tag OUTSIDE the <sql> tag for that to work.
Thanks.

Creating/replacing packages using Liquibase

$
0
0
I'm using Liquibase to apply development changes to QA environments. I have both table and DML changes working great via Liqibase. I've tried to push packages and their bodies using:

  1.     <changeSet id="6006" author="EA" runAlways="true">
  2.         <sqlFile path="sql/db_api.sql" splitStatements="false"/>
  3.         <rollback>
  4.             <sqlFile path="../Rollback/db_api.sql" splitStatements="false"/>
  5.         </rollback>
  6.     </changeSet>
The packages are very large (500-800KB) thus I'm not applying them using the <sql> option. When I run Liqibase with the 'update' flag, the update fails with:
  1.   
  2. END; -- Procedure pr_Logout

  3. END; -- Package Body pa_Handle_Users, Error Msg = ORA-00922: missing or invalid
  4. option

  5.        at oracle.jdbc.driver.T4CTTIoer11.processError(T4CTTIoer11.java:498)
The actual file's tail looks like this:

  1.                                     p_ThreadId     => p_ThreadId );

  2.     END; -- Procedure pr_Logout

  3.  END; -- Package Body pa_Handle_Users
  4. /

The file has a slash at the end, while Liquibase's error does not show it. Could this be related?

Liquibase and SQL Server 2016

$
0
0
Hello,

We are using liquibase for schema creation and upgrades over different versions. The issue we are facing is with SQL Server 2016 and 2017. Its working fine till 2014. 

Here is what we need

We need to drop a column and its constraints. The column is a boolean column with a default value. We are using the following in the changeset to achieve this

<dropDefaultValue tableName="<tablename>" columnName="<columnname>"/>
<dropColumn columnName="<columnname>" tableName="<tablename>"/>

We are seeing following error

DROP CONSTRAINT select d.name from syscolumns c,sysobjects d, sysobjects t where c.id=t.id AND d.parent_obj=t.id AND d.type='D' AND t.type='U' AND c.name='columnname' AND t.name='tablename'

the above select query returns two records for us both in SQL Server 2012 and 2016. The complete(Drop constraint) query seems to be working in 2012 but it fails in 2016.

Any pointers and help is appreciated.

Regards,
Sumti

How to add preconditions into changeset with code

$
0
0
How to add preconditions into changeset with code?
In my code, use XMLChangeLogSerializer to generage changeset log file, 
  1. xmlChangeLogSerializer.write(databaseChangeLog.getChangeSets(), fos);
but changeSet can not add precondition, have some solution?

From code, only addChange() and setPreconditions(), but PreconditionContainer have no any Precondition.

Oracle endDelimiter pbm

$
0
0
Hello all.

I wonder why I did not see such a pbm there or elwhere in the net... peharps I'm a noob ^^

The pbm I face off is when I run liquibase to create packages, the "/" symbol from my division has been red as an endDelimiter : 

ex : 

my package function : 

Create or replace Package (name) AS
[...]

  PROCEDURE GETPROCESSED(data in, data out)
  IS
  BEGIN
    [...]   
    select  CASE WHEN RequestTypeId = 1 THEN 1 ELSE 0 END "ARCHIVAGE"
           ,CASE WHEN RequestTypeId = 2 THEN 1 ELSE 0 END "PURGE"
    from request rt INNER JOIN requestdispatch rd
    ON rt.id = rd.requestid
    where rt.dispatchstatus = 2
    AND rt.dispatchdate >= (SYSDATE - pIntervalInSec/86400)
    ) A;
[...]

End (name);
/


changelog file : 

  <changeSet author="InstallStructure" id="DatabasePackage-WARCHI" failOnError="true" runAlways="true" runOnChange="true" context="renew or install" >
    <sqlFile dbms="oracle"  encoding="UTF8" endDelimiter="/" splitStatements="true" stripComments="true" path="../SQL/00-install/04-Packages/Pckg_WARCHI_20180621.sql" />
  </changeSet>


As a result the following error : 

Unexpected error running Liquibase: ORA-00900: invalid SQL statement
 [Failed SQL: 86400)
    ) A;

  END (name);



Where am I wrong please ?

thaznk you for helping

Why does Liquibase generate needless statements?

$
0
0
I am using liquibase 3.5.5 and have generated a changelog file from my oracle database but the changelogs are somehow strange since there are always two statements for creating an index and then adding a constraint primary key with the same name. The creating of an index before adding the primary key is not necessary I think and in the SQL files which I have used to generate my origin Oracle database it was not like that as well. Here is an example of the liquibase changelog:


<changeSet author="Ferid (generated)" id="1528876614155-108">
<createIndex indexName="BP_PK" tableName="BP_RESULTS" unique="true">
<column name="BP_ID"/>
</createIndex>
<addPrimaryKey columnNames="BP_ID" constraintName="BP_PK" tableName="BP_RESULTS"/>
</changeSet>
<changeSet author="Ferid (generated)" id="1528876614155-109">
<createIndex indexName="CS_PK" tableName="CHECK_STATUS" unique="true">
<column name="CS_ID"/>
</createIndex>
<addPrimaryKey columnNames="CS_ID" constraintName="CS_PK" tableName="CHECK_STATUS"/>
</changeSet>
<changeSet author="Ferid (generated)" id="1528876614155-110">
<createIndex indexName="CS_SETS_PK" tableName="CONFIG_SETS" unique="true">
<column name="CONFIG_ID"/>
</createIndex>
<addPrimaryKey columnNames="CONFIG_ID" constraintName="CS_SETS_PK" tableName="CONFIG_SETS"/>
</changeSet>


When I generate a SQL file (for Microsoft SQL Server, but this happens for every other database as well, even Oracle itself) from this changelog it would look like this:


-- Changeset C:/Users/Ferid/Downloads/liquibase-3.5.5-bin/sdk/workspace/changelog/com/example/newChangelog.xml::1528876614155-108::Ferid (generated)
CREATE UNIQUE NONCLUSTERED INDEX BP_PK ON [BP_RESULTS]([BP_ID])
GO

ALTER TABLE [BP_RESULTS] ADD CONSTRAINT [BP_PK] PRIMARY KEY ([BP_ID])
GO

-- Changeset C:/Users/Ferid/Downloads/liquibase-3.5.5-bin/sdk/workspace/changelog/com/example/newChangelog.xml::1528876614155-109::Ferid (generated)
CREATE UNIQUE NONCLUSTERED INDEX CS_PK ON [CHECK_STATUS]([CS_ID])
GO

ALTER TABLE [CHECK_STATUS] ADD CONSTRAINT [CS_PK] PRIMARY KEY ([CS_ID])
GO

-- Changeset C:/Users/Ferid/Downloads/liquibase-3.5.5-bin/sdk/workspace/changelog/com/example/newChangelog.xml::1528876614155-110::Ferid (generated)
CREATE UNIQUE NONCLUSTERED INDEX CS_SETS_PK ON [CONFIG_SETS]([CONFIG_ID])
GO

ALTER TABLE [CONFIG_SETS] ADD CONSTRAINT [CS_SETS_PK] PRIMARY KEY ([CONFIG_ID])
GO


In the origin oracle database these primary keys were added like this and there is no second statement that creates an index first:


ALTER TABLE BP_RESULTS ADD (CONSTRAINT BP_PK PRIMARY KEY(BP_ID) ENABLE VALIDATE);
ALTER TABLE CHECK_STATUS ADD (CONSTRAINT CS_PK PRIMARY KEY(CS_ID) ENABLE VALIDATE);
ALTER TABLE CONFIG_SETS ADD (CONSTRAINT CS_SETS_PK PRIMARY KEY(CONFIG_ID) ENABLE VALIDATE);


I generate the changelog file via command-line like this:


.\liquibase `
--driver=oracle.jdbc.OracleDriver `
--classpath=C:/svn_planio/TST/resources/lib/ojdbc7.jar `
--changeLogFile=C:\Users/Ferid/Downloads/liquibase-3.5.5-bin/sdk/workspace/changelog/com/example/newChangelog.xml `
--url="jdbc:oracle:thin:@localhost:1521:fer" `
--username=username `
--password=password `
generateChangeLog


Is there any way to let liquibase generate the changelogs in an other way? Maybe adding something when generating the changelog file via command line? Or do I have to change something in my origin database?

Databases not within the if/else conditions in JdbcDatabaseSnapshot need to query from table_constraints

$
0
0
There are two classes (JdbcDatabaseSnapshot.java and UniqueConstraintSnapshotGenerator.java) with a general else condition that queries for a "constraints" table for sql generation...


"select CONSTRAINT_NAME, CONSTRAINT_TYPE, TABLE_NAME "
                                + "from " + database.getSystemSchema() + ".constraints "
                                + "where constraint_schema='" + jdbcSchemaName + "' "
                                + "and constraint_catalog='" + jdbcCatalogName + "' "
                                + "and constraint_type='UNIQUE'";

The ".constraints" should be changed to the standard ".table_constraints" because "constraints" is a reserved keyword in other databases. This issue is unfortunate because your can not override this particular method to extend the database.

I'm using the previously development Intersystems Cache extension but still fail in generateChangeLog since this query is not allowed.  

This is my first time post so I hope this is in the proper place.  Thanks!

Oracle Wallet Reference

$
0
0
Hi there,
  Can anyone please advise how to reference an Oracle wallet to connect instead of username & password in Liquibase command or Properties file ?
I have an Oracle wallet configured but just wondering how I could use it to connect.
Thanks,
Atef

What is meant by the phrase adapter/connector?

$
0
0

This is a basic questions. I want to apply to an entry level java developer position with the following requirement:

Familiarity with the Sailpoint Identity IQ standard adapters/connectors

By standard connectors do they basically mean how Sailpoint exchanges data with third party tools? And by adapter do they mean that the adapter pattern would be used? 

MySQL diffChangeLog converts VARCHAR(50) to VARCHAR(50 BYTE) and other oddities

$
0
0
We are using liquibase to generate change logs for MySQL database.

When creating a change log it seems to convert VARCHAR(50) to VARCHAR(50 BYTE), INT to INT(10) among other things.

VARCHAR(50 BYTE) is not even a valid MySQL syntax.

This is odd and is requiring manual rework each time a changeset is generated. This is the command we run. The issue happens with both 3.5.4 and 3.6.2, upgrade didn't help:

liquibase --driver=com.mysql.jdbc.Driver '--url=jdbc:mysql://target' --username=*** --password=****** --diffTypes=tables,columns,indexes,views,foreignkeys,primarykeys,uniqueconstraints diffChangeLog '--referenceUrl=jdbc:mysql://reference' --referenceUsername=*** --referenceDriver=com.mysql.jdbc.Driver --referencePassword=*********


What are we missing? Any command line settings?

Viewing all 2993 articles
Browse latest View live


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