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

Re : NullPointerException when running generateChangeLog using MySQL and Liquibase 3.2.2


Re : generatechangelog creates changelog with most tables without column

$
0
0
Were you ever able to resolve this? I'm running into a similar issue now using Liquibase 3.2.2 and MySQl 5.6.  Out of approximately 200 tables in my database (all of which have columns), only 2 show up with columns in the changeLog.xml.

Otherwise I just see a bunch of the following:
  1.     <changeSet author="eddie (generated)" id="1409095248246-137">
  2.         <createTable tableName="sessions"/>
  3.     </changeSet>

Generate XML/ SQL output with data types of target database

$
0
0

I need to convert the structure of PostgreSQL databases to Oracle. In PostgreSQL, I have a postgres database with data. In Oracle I have a blank database in which I want to write postgres database which in PostgreSQL.

In fact, I do not need the data, only the structure (relationships).

For this I use Liquibase. I get the changelog from PostgreSQL with the command:

  1. liquibase \
       --driver=org.postgresql.Driver \
       --classpath="C:\db_drivers\postgresql-9.3-1102.jdbc3.jar" \
       --changeLogFile="./postgresql_changelog.xml" \
       --url="jdbc:postgresql://localhost:5432/postgres" \
       --username=schema_name_here \
       --password=************** \
       --logLevel=debug \
       --defaultSchemaName=sep \
       generateChangeLog

After this I try to create objects in the Oracle database:

  1. liquibase
       --driver=oracle.jdbc.OracleDriver
       --classpath="C:\db_drivers\ojdbc14.jar"
       --changeLogFile="./postgresql_changelog.xml"
       --url="jdbc:oracle:thin:@ip_here:orabeta"
       --username=***
       --password=***
       update

Does not work:  ORA-00902

Here is a fragment of postgresql_changelog.xml:

  1. ...
    <changeSet author="Alexey (generated)" id="1409146335011-53">
    <createTable tableName="TABLE1A">
    <column name="total_pk" type="INT8">
    <constraints nullable="false"/>
    </column>
    <column name="form_fk" type="INT8">
    <constraints nullable="false"/>
    </column>
    ...

I also generate a pure SQL- file:

  1. liquibase
       --driver=oracle.jdbc.OracleDriver
       --classpath="C:\db_drivers\ojdbc14.jar"
       --changeLogFile="./postgresql_changelog.xml"
       --url="jdbc:oracle:thin:@ip_here:orabeta"
       --username=***
       --password=***
       updateSQL > update.sql

Here is a fragment of update.sql:

  1. ...
    CREATE TABLE SCHEMA_HERE.TABLE1A (total_pk INT8 NOT NULL, form_fk INT8, .....etc );
    INSERT INTO SCHEMA_HERE.TABLE1A (ID, FORM_ID, ...etc)
    ...

I would like to generate the file, in which all data types correspond to the target database, ie that I want to create. I can write a simple parser that replace data types, but it is not the right solution - can be many database.

It possible to generate XML/ SQL output with data types of target database?

Or maybe there is an option that allow to generate output with "abstract" data types? Ie with the data types that are not in the real databases, for example, instead of INT8 - Integer, etc.

I would be very grateful for the information. Thanks to all.

Create another database from changelog: automatic data type conversion issue

$
0
0
I get the changelog from PostgreSQL database with the command:

  1. liquibase \
  2.    --driver=org.postgresql.Driver \
  3.    --classpath="C:\db_drivers\postgresql-9.3-1102.jdbc3.jar" \
  4.    --changeLogFile="./postgresql_changelog.xml" \
  5.    --url="jdbc:postgresql://localhost:5432/postgres" \
  6.    --username=schema_name_here \
  7.    --password=************** \
  8.    --logLevel=debug \
  9.    --defaultSchemaName=sep \
  10.    generateChangeLog

Here is a fragment of postgresql_changelog.xml:

  1. ...
    <createTable tableName="table1">
        <column name="total_pk" type="INT8">
            <constraints nullable="false"/>
        </column>
        <column name="form_fk" type="INT8">
            <constraints nullable="false"/>
        </column>
        <column name="territory_fk" type="INT8">
            <constraints nullable="false"/>
        </column>
        <column name="parameter_fk" type="INT8">
            <constraints nullable="false"/>
        </column>
        <column name="enterprise_fk" type="INT8">
            <constraints nullable="false"/>
        </column>
        <column name="total_g" type="INT8">
            <constraints nullable="false"/>
        </column>
        <column name="total_data" type="date">
            <constraints nullable="false"/>
        </column>
        <column name="total_value" type="numeric(*, 2)">
            <constraints nullable="false"/>
        </column>
        <column name="variant_fk" type="INT8">
            <constraints nullable="false"/>
        </column>
        <column name="period_id" type="INT8">
            <constraints nullable="false"/>
        </column>
        <column name="total_q" type="INT8"/>
        <column name="total_m" type="INT8"/>
        <column name="increase" type="INT8"/>
        <column name="period_index" type="INT8"/>
        <column name="data_input" type="TIMESTAMP WITHOUT TIME ZONE"/>
        <column name="document_unid" type="VARCHAR(64)"/>
        <column name="value_comment" type="VARCHAR(512)"/>
        <column name="olap_year" type="SMALLINT"/>
        <column name="olap_month" type="SMALLINT"/>
        <column name="olap_week" type="SMALLINT"/>
        <column name="olap_day_of_month" type="SMALLINT"/>
        <column name="olap_quarter" type="VARCHAR(4)"/>
        <column name="olap_quarter_desc" type="VARCHAR(17)"/>
        <column name="olap_month_name" type="VARCHAR(8)"/>
        <column name="ediz_id" type="INT8">
            <constraints nullable="false"/>
        </column>
        <column name="olap_month_code" type="VARCHAR(10)"/>
        <column name="olap_month_caption" type="VARCHAR(64)"/>
    </createTable>
    ...

Now I want to create the same objects and the same relationships in another database (Oracle):

  1. liquibase
       --driver=oracle.jdbc.OracleDriver
       --classpath="C:\db_drivers\ojdbc14.jar"
       --changeLogFile="./postgresql_changelog.xml"
       --url="jdbc:oracle:thin:@ip_here:orabeta"
       --username=***
       --password=***
       update

But it does not work: ORA-00902

It is possible to get changelog from one database and update another database in different RDBMS server from this changelog? I need to get automatic data type conversion.

Re : Generate XML/ SQL output with data types of target database

$
0
0

Actually, it is necessary to manually correct the data types in the generated file. Data types are not converted automatically.

For example:

  1. ...
  2. <changeSet author="Alexey (generated)" id="1409146335011-53">
  3.    <createTable tableName="TABLE1A">
  4.       <!-- replace INT8 to NUMBER(16) for Oracle (for example) -->
  5.       <column name="total_pk" type="INT8">           
  6.          <constraints nullable="false"/>
  7.       </column>
  8.       <!-- replace INT4 to NUMBER(10) for Oracle (for example) -->
  9.       <column name="form_fk" type="INT4"> 
  10.          <constraints nullable="false"/>
  11.       </column>   
  12. ...

After that execute the command:

  1. liquibase 
  2.    --driver=oracle.jdbc.OracleDriver 
  3.    --classpath="C:\db_drivers\ojdbc14.jar" 
  4.    --changeLogFile="./postgresql_changelog.xml" 
  5.    --url="jdbc:oracle:thin:@ip_here:orabeta" 
  6.    --username=*** 
  7.    --password=***
  8.    update

The structure will be generated on the target database. Is similarly possible migrate the data (option --diffTypes = "data").

But, really, can be used "abstract" data types, as write in the documentation: Liquibase, Column tag


To help make scripts database-independent, the following “generic” data types will be converted to the correct database implementation: BOOLEAN CURRENCY UUID CLOB BLOB DATE DATETIME TIME BIGINT

Also, specifying a java.sql.Types.* type will be converted to the correct type as well. If needed, precision can be included. Here are some examples: java.sql.Types.TIMESTAMPjava.sql.Types.VARCHAR(255)


And possible to make the copy of structure without DDL (and data without DML).

Re : Create another database from changelog: automatic data type conversion issue

$
0
0
The answer is -  yes . But it is necessary to manually correct the data types in the generated file. Data types are not converted automatically.

MySql: DateTime size doesn't get picked by createTable / addColumn changesets

$
0
0
Running the following changeset using liquibase-3.2.2 (on mySql 5.6):
  1. < createTable   tableName = "myTable" >   
  2.     < column   name = "myId"   type = "BIGINT(20) UNSIGNED" >   
  3.         < constraints   nullable = "false" />   
  4.     </ column >   
  5.      < column   name = "my_time"   type = "datetime(3)" >   
  6.         < constraints   nullable = "false" />   
  7.     </ column >   
  8. </ createTable>

Will create the "my_time" column with "datetime" type instead of "datetime(3)" type, which means - it won't store milliseconds.
As a workaround, I create the table using <sql> changeset.

(also, FYI, I couldn't find a way to open a JIRA ticket in https://liquibase.jira.com/ - it didn't allow me to create a user using any of my email addresses saying my domain is not allowed)

MySql: Can't create non-PK column with autoIncrement using createTable changesets

$
0
0
Running the following changeset using liquibase-3.2.2 (on mySql 5.6):
< createTable   tableName = "myTable"   >     
     < column   name = "myId1"   type   =   "BIGINT(20) UNSIGNED"   >     
         < constraints    nullable = "false"   />     
     </ column >  
    < column   name = "myId2"   type   =   "BIGINT(20) UNSIGNED"   >     
         < constraints    nullable = "false"   />     
     </ column >  
       < column   name = "order"     autoIncrement = "true"   type = "BIGINT(20) UNSIGNED"   >     
         < constraints   nullable = "false"   />     
     </ column >     
</ createTable>
< addPrimaryKey   columnNames = "myId1, myId2"   constraintName = "PRIMARY"   tableName = "myTable" />   
< createIndex   indexName = "order_sort_idx"   tableName = "myTable"   unique = "false" >   
     < column   name = "order" />   
</ createIndex >  

will throw the following error during execution: Incorrect table definition; there can be only one auto column and it must be defined as a key

The reason is that liquibase runs each of the elements one at a time. if the <createIndex > would have run with the <createTable> change, the error wouldn't have been thrown.

As a workaround, I create the table using <sql> changeset:
< sql >   
    CREATE TABLE `myTable ` (  
        `myId1` bigint(20) unsigned NOT NULL,  
        `myId2` bigint(20) unsigned NOT NULL,  
        `order` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
        PRIMARY KEY (`myId1`,`myId2`),  
        KEY `order_sort_idx` (`order` ASC)  
    );  
</ sql >   

(also, FYI, I couldn't find a way to open a JIRA ticket in https://liquibase.jira.com/ - it didn't allow me to create a user using any of my email addresses saying my domain is not allowed)

cannot sign up on liquibase.jira.com

$
0
0
I can't currently sign up to liquibase.jira.com. My email is rejected as not coming from an allowed domain: 

Whoops! The email address provided is not from an allowed domain. 

Seems to be a recent Jira OnDemand regression, and maybe the same issue as:
  https://jira.atlassian.com/browse/AOD-7398 - Self Sign up cannot be enabled in OnDemand

Workaround (according to AOD-7398): "Please contact Atlassian Support to have a workaround applied to your instance."

Could not initialize class liquibase.sqlgenerator.core.LockDatabaseChangeLogGenerator

$
0
0
Getting this issue when I try to run maven test. Not sure what's causing the issue as these test ran before without issues. My dependencies are being managed by maven    

  1.     Caused by: java.lang.NoClassDefFoundError: Could not initialize class liquibase.sqlgenerator.core.LockDatabaseChangeLogGenerator
  2. at sun.reflect.GeneratedConstructorAccessor379.newInstance(Unknown Source)
  3. at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
  4. at java.lang.reflect.Constructor.newInstance(Constructor.java:408)
  5. at liquibase.sqlgenerator.SqlGeneratorFactory.<init>(SqlGeneratorFactory.java:39)
  6. at liquibase.sqlgenerator.SqlGeneratorFactory.getInstance(SqlGeneratorFactory.java:53)
  7. at liquibase.executor.AbstractExecutor.applyVisitors(AbstractExecutor.java:22)
  8. at liquibase.executor.jvm.JdbcExecutor.access$500(JdbcExecutor.java:35)
  9. at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:284)
  10. at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:54)
  11. at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:106)
  12. at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:96)
  13. at liquibase.lockservice.StandardLockService.init(StandardLockService.java:83)
  14. at liquibase.lockservice.StandardLockService.acquireLock(StandardLockService.java:182)
  15. at liquibase.lockservice.StandardLockService.waitForLock(StandardLockService.java:148)
  16. at liquibase.Liquibase.update(Liquibase.java:189)
  17. at liquibase.Liquibase.update(Liquibase.java:181)
  18. at liquibase.integration.spring.SpringLiquibase.performUpdate(SpringLiquibase.java:342)
  19. at liquibase.integration.spring.SpringLiquibase.afterPropertiesSet(SpringLiquibase.java:299)
  20. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1571)
  21. at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1509)

Re : Could not initialize class liquibase.sqlgenerator.core.LockDatabaseChangeLogGenerator

$
0
0
Any time you see a NoClassDefFound error, the problem is almost certainly an issue with the classpath. You can diagnoze the issue further by running maven with the -X switch to enable debug output. 

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

Re : MySql: DateTime size doesn't get picked by createTable / addColumn changesets

$
0
0

(also, FYI, I couldn't find a way to open a JIRA ticket in  https://liquibase.jira.com/  - it didn't allow me to create a user using any of my email addresses saying my domain is not allowed)
 

Same here, started a thread on that.

generateChangeLog don't identify different schemas, just "dbo" (MSSQL 2008)

$
0
0
Hello!

I'm studying using liquibase in our project. We have a database in SQL Server 2008, with 2 schemas and this schemas are different from "dbo".

When I test the generateChangeLog in a database with schema "dbo", just the objects inside this schema are created in the changelog file.

But, when I try in our project database, no record is created.

Re : generateChangeLog don't identify different schemas, just "dbo" (MSSQL 2008)

$
0
0
You might try setting logLevel=DEBUG in you liquibase.properties file to get a better idea what liquibase is doing in this case. 

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

tagDatabase not taged

$
0
0
Here is about my changelog:
-----------------------------
<changeSet id="1" author="biker">
<tagDatabase tag="v0"/>
</changeSet>
<changeSet id="2" author="biker">
<sqlFile  path="view1.sql" relativeToChangelogFile="true" />
<rollback>
drop view v_test
</rollback>
</changeSet>
<changeSet id="3" author="biker">
<tagDatabase tag="v1"/>
</changeSet>
<changeSet id="4" author="biker">
<sqlFile path="view2.sql" relativeToChangelogFile="true"/>
<rollback changeSetId="2" changeSetAuthor="biker"/>
</changeSet>
<changeSet id="5" author="biker">
<tagDatabase tag="v2"/>
</changeSet>
<changeSet id="6" author="biker">
<sqlFile path="view3.sql" relativeToChangelogFile="true"/>
<rollback changeSetId="4" changeSetAuthor="biker"/>
</changeSet>
<changeSet id="7" author="biker">
<tagDatabase tag="v3"/>
</changeSet>
------------------------------------
I set some tags in changelog and want to rollback to "v0" "v1" ...  with "rollback tag-name".when I executed the changelog, I found the table databasechangelog in database is like this 

Obviously,the tag 'v2' is missed. so I can't rollback to 'v2'. and why this happened?    

Re : tagDatabase not taged

$
0
0
In above case, my database is mysql. when I changed to oracle,it works well.  I guess the problem maybe about the precision of the column dateexecuted .  It is different in mysql and oracle

Re : Could not initialize class liquibase.sqlgenerator.core.LockDatabaseChangeLogGenerator

$
0
0
Ok so I added the -X flag but, still unsure what is causing this issue. See link for stacktrace. 

Liquibase 3.3 with Vertica DB : "DATABASECHANGELOG" already exists

$
0
0
Hi,

I have an issue when using Liquibase on Vertica DB.
The first execution works but the second time I have the following message :
DEBUG 9/3/14 10:30 AM: liquibase: Executing UPDATE database command: UPDATE VDMFIDEV1.DATABASECHANGELOGLOCK SET LOCKED = FALSE, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1
INFO 9/3/14 10:30 AM: liquibase: Successfully released change log lock
Unexpected error running Liquibase: [Vertica][VJDBC](4213) ROLLBACK: Object "DATABASECHANGELOG" already exists

SEVERE 9/3/14 10:30 AM: liquibase: [Vertica][VJDBC](4213) ROLLBACK: Object "DATABASECHANGELOG" already exists
liquibase.exception.DatabaseException: Error executing SQL CREATE TABLE VDMFIDEV1.DATABASECHANGELOG (ID VARCHAR(255) NOT NULL, AUTHOR VARCHAR(255) NOT NULL, FILENAME VARCHAR(255) NOT NULL, DATEEXECUTED datetime NOT NULL, ORDEREXECUTED INT NOT NULL, EXECTYPE VARCHAR(10) NOT NULL, MD5SUM VARCHAR(35), DESCRIPTION VARCHAR(255), COMMENTS VARCHAR(255), TAG VARCHAR(255), LIQUIBASE VARCHAR(20)): [Vertica][VJDBC](4213) ROLLBACK: Object "DATABASECHANGELOG" already exists
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:62)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:122)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:112)
        at liquibase.changelog.StandardChangeLogHistoryService.init(StandardChangeLogHistoryService.java:172)
        at liquibase.Liquibase.checkLiquibaseTables(Liquibase.java:716)
        at liquibase.Liquibase.update(Liquibase.java:189)
        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.SQLSyntaxErrorException: [Vertica][VJDBC](4213) ROLLBACK: Object "DATABASECHANGELOG" already exists
        at com.vertica.util.ServerErrorData.buildException(Unknown Source)
        at com.vertica.dataengine.VQueryExecutor.executeSimpleProtocol(Unknown Source)
        at com.vertica.dataengine.VQueryExecutor.execute(Unknown Source)
        at com.vertica.jdbc.common.SStatement.executeNoParams(Unknown Source)
        at com.vertica.jdbc.common.SStatement.execute(Unknown Source)
        at liquibase.executor.jvm.JdbcExecutor$ExecuteStatementCallback.doInStatement(JdbcExecutor.java:310)
        at liquibase.executor.jvm.JdbcExecutor.execute(JdbcExecutor.java:55)
        ... 9 more
Caused by: com.vertica.support.exceptions.SyntaxErrorException: [Vertica][VJDBC](4213) ROLLBACK: Object "DATABASECHANGELOG" already exists

I'm using Vertica Jdbc driver : vertica-jdbc-7.1.0-0.jar.
It is weird because Liquibase can see the databasechangeloglock table but not the databasechangelog  table which are in the same schema.

I have also tried to add Vertica extension but I have this exception :
Unexpected error running Liquibase: liquibase.exception.UnexpectedLiquibaseException: java.lang.NoSuchMethodError: liquibase.datatype.DataTypeFactory.fromDescription(Ljava/lang/String;)Lliquibase/datatype/LiquibaseDataType;

SEVERE 9/3/14 10:39 AM: liquibase: liquibase.exception.UnexpectedLiquibaseException: java.lang.NoSuchMethodError: liquibase.datatype.DataTypeFactory.fromDescription(Ljava/lang/String;)Lliquibase/datatype/LiquibaseDataType;
liquibase.exception.ChangeLogParseException: liquibase.exception.UnexpectedLiquibaseException: liquibase.exception.UnexpectedLiquibaseException: java.lang.NoSuchMethodError: liquibase.datatype.DataTypeFactory.fromDescription(Ljava/lang/String;)Lliquibase/datatype/LiquibaseDataType;


Does anynone know how to fix this issue ?

Thanks
M.Boutkhil

Re : generateChangeLog don't identify different schemas, just "dbo" (MSSQL 2008)

$
0
0
Tnks in reply Steve!

I tried what you say, and I got the query executed. Tnks!

But now, I saw that it only runs for only one schema.

Now, I have two questions:

  1. How can I generate to all my schemas?
  2. How can I put the schema name in my changelog?
Thanks again!

Attribute 'onUpdateSQL' is not allowed to appear in element 'preConditions'

$
0
0
Hi, I have the following changeLog.xml:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <databaseChangeLog
  3.         xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
  4.         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5.         xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
  6.         xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.3.xsd
  7.         http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
  8.     <changeSet id="2" author="emi">
  9.         <preConditions onFail="MARK_RAN" onUpdateSQL="RUN">
  10.           <not>
  11.             <tableExists tableName="a" />
  12.           </not>
  13.         </preConditions>
  14.         <createTable tableName="a">
  15.             <column name="b" type="tinyint(4)" />
  16.         </createTable>
  17.     </changeSet>
  18. </databaseChangeLog>

This is what happens when I run an updateSQL on it:

$ ./liquibase updateSQL
Unexpected error running Liquibase: cvc-complex-type.3.2.2: Attribute 'onUpdateSQL' is not allowed to appear in element 'preConditions'.

What's wrong?
Viewing all 2993 articles
Browse latest View live


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