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

Re : loadData + CSV + computedValue

$
0
0
Hi,

That's great! I'd like to use it also.
I just don't see how could you use / test your change. I don't see any code populating valueComputed from the changeLog file. Do I miss something?
Your pull request is against the master do you know when it will be released?

Thanks,
  Gyula

Re : loadData + CSV + computedValue

$
0
0
My change is about loadData change, so the example would be something like this

create table

<changeSet id="my_table" author="me">
    <createTable tableName="my_table">
        <column name="my_column" type="varchar">
            <constraints primaryKey="true"/>
        </column>
        <column name="my_foreign_column" type="integer">
            <constraints foreignKeyName="fk_my_foreign_table"
                             references="my_foreign_table(id)"/>
        </column>
    </createTable>
</changeSet>

load data

<changeSet id="load_data" author="me">
    <loadData file="data.csv"
                  tableName="my_table">
        <column header="my_column" name="my_column" type="STRING"/>
        <column header="my_foreign_column" name="my_foreign_column" type="COMPUTED"/>
    </loadData>
</changeSet>

and CSV (my_foreign_table is already created and populated)

my_column,my_foreign_column
"myValue","select id from my_foreign_table where some_column='some_value'"

Zbynek

JSON column type for PostgreSQL, Oracle, MSSqlServer and H2

$
0
0
Hi all,

I'm a Liquibase beginner and I'm not finding the way to specify a JSON type in Liquibase documentation (https://www.liquibase.org/documentation/column.html)

For PostgreSQL I found this simple answer https://forum.liquibase.org/topic/how-to-add-jsonb-columns-for-postgresql so I'm supposing to create one separate column definition for each dbms I have to manage, is this the right way to use Liquibase to manage such a situation?

Currently I'm writing only create table changeset.

Thanks and best regards
Raffaele

Re : loadData + CSV + computedValue

$
0
0
Hi,

Oh... sure in the CSV...

Thanks,
   Gyula

Stack map does not match the one at exception handler 602 Error

$
0
0
Hi

We have deployed Liquibase in Devloppement and Rct environment with succes 
But in Production environment we have following error message
SpringBoot failed to start and Tomcat 8.5.46 stop !

Where is problem ?
Regards
  1. 2020-01-16 08:31:05.202 [default-startStop-1] WARN  o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext.refresh - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.toto.soa.autoconfigure.SdfwProviderConfiguration': Invocation of init method failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'contractNotificationV1Impl': Unsatisfied dependency expressed through field 'softwareServiceInterfaceService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'softwareServiceInterfaceServiceImpl': Unsatisfied dependency expressed through field 'softwareServiceInterfaceRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'softwareServiceInterfaceRepository': Cannot create inner bean '(inner bean)#759fad80' of type [org.springframework.orm.jpa.SharedEntityManagerCreator] while setting bean property 'entityManager'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name '(inner bean)#759fad80': Cannot resolve reference to bean 'orcaEntityManagerFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'liquibase' defined in class path resource [org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration$LiquibaseConfiguration.class]: Invocation of init method failed; nested exception is java.lang.VerifyError: Stack map does not match the one at exception handler 602
  2. Exception Details:
  3.   Location:
  4.     com/datical/liquibase/ext/storedlogic/trigger/change/CreateTriggerGenerator.generateSql(Lcom/datical/liquibase/ext/storedlogic/trigger/change/CreateTriggerStatement;Lliquibase/database/Database;Lliquibase/sqlgenerator/SqlGeneratorChain;)[Lliquibase/sql/Sql; @602: dup
  5.   Reason:
  6.     Type 'java/lang/String' (current frame, locals[3]) is not assignable to 'liquibase/sqlgenerator/SqlGeneratorChain' (stack map, locals[3])
  7.   Current Frame:
  8.     bci: @11
  9.     flags: { }
  10.     locals: { 'com/datical/liquibase/ext/storedlogic/trigger/change/CreateTriggerGenerator', 'com/datical/liquibase/ext/storedlogic/trigger/change/CreateTriggerStatement', 'liquibase/database/Database', 'java/lang/String', top, top, top, top, 'com/wily/introscope/agent/trace/IMethodTracer' }
  11.     stack: { 'java/lang/Throwable' }
  12.   Stackmap Frame:
  13.     bci: @602
  14.     flags: { }
  15.     locals: { 'com/datical/liquibase/ext/storedlogic/trigger/change/CreateTriggerGenerator', 'com/datical/liquibase/ext/storedlogic/trigger/change/CreateTriggerStatement', 'liquibase/database/Database', 'liquibase/sqlgenerator/SqlGeneratorChain', top, top, top, top, 'com/wily/introscope/agent/trace/IMethodTracer' }
  16.     stack: { 'java/lang/Throwable' }
  17.   Bytecode:


3.8.5-local-SNAPSHOT instead of 3.8.5 from https://github.com/liquibase/liquibase/releases/tag/v3.8.5

$
0
0
Hi Liquibase,

3.8.5-local-SNAPSHOT instead of 3.8.5 from https://github.com/liquibase/liquibase/releases/tag/v3.8.5

3.8.5 base.pom.xml:
        <liquibase.base.version>3.8.5</liquibase.base.version>
        <liquibase.version.qualifier>-local</liquibase.version.qualifier>
        <liquibase.version.snapshot>-SNAPSHOT</liquibase.version.snapshot>
        <liquibase.version>${liquibase.base.version}${liquibase.version.qualifier}${liquibase.version.snapshot}</liquibase.version>

(Recompiling latest to have built from source in house at my employer Oracle).

(same -local-SNAPSHOT issue with 3.8.4).

Thank you for your time,
Turloch O'Tierney


Manually updated sql, how to sync databasechangelog table (md5). ClearCheckSums & gradle ?

$
0
0
Hi all,
Currently there have been some manual update work done to directly to the database. And after deploying the application, the databasechangelock has gone locked, and sql-xml-scripts are more like placeholders for database structure ( and the changes to database have not been stacked as separated files).

I would like to get liquibase back into sync with the scripts, so that it would possible to write new changes as new scripts and run DB changes trough liquibase. Currently the databasechangelock is locked and running the liquibase fails, for what I believe, because the checksum is not correct. I have 5 separated scripts to database ( 3 of them have changed after first run). I understood that clearCheckSums could be the key fo re-running and opening the lock. But how I run the command (not on cmd) with gradle/springboot, is it possible to add as a tag inside <databasechangelog> in the actual script?

I'm also little unsure what will happen to the database and the data in database, will it stay untouched, and will it only create new MD5 checksums to the table? 
Or should I use combination of <tableExist> with <clearCheckSums> to make sure liquibase wont deal with database, and just sets liquibase changelog md5 sums back into sync and open lock?

Or can I brutally delete checksums, and re-deploy without loosing the data? 

Kind regards,
touch

Liquibase Not Assigning Right Default Values to primary key columns in SQL Server database

$
0
0
0

I have generated a generateChangelog on a current database, I have attempted to create a new database from that changelog using update/updateSQL(tried both). I've come across some strange behaviour as below.

When trying to create tables on the new database with the changelog, faced the following problems:

  • Default Value of the column is changed from NOT NULL to NULL on column A.
  • Problem "a" is causing another issue which is "Cannot define PRIMARY KEY constraint on nullable column in table 'column A'

Any information as to why liquibase does that and how to prevent it doing the above behavior ? I can't find any mention of it in the docs or any other mention of this behavior online. We have several databases and manually fixing these changes will be a hurdle.


Re : Liquibase Not Assigning Right Default Values to primary key columns in SQL Server database

$
0
0
Could you include the changelog that was created, the command you used, and details on the database platform?

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

Re : Manually updated sql, how to sync databasechangelog table (md5). ClearCheckSums & gradle ?

$
0
0
A lot of questions in here - I'll try to answer as best I can.

The first issue with the databasechangeloglock - this sometimes happens when an update operation is interrupted. There are two ways to unlock it - one is using SQL directly in whatever SQL tool you use, and to run "UPDATE DATABASECHANGELOGLOCK SET LOCKED=0" This is described a bit more in the documentation at https://www.liquibase.org/documentation/databasechangeloglock_table.html

The second way to do it is using the built in releaseLocks command, which is available as a maven goal: https://www.liquibase.org/documentation/maven/maven_releaselocks.html

Next issue -you mention that you think the commands are failing because the checksums are not correct - that may also be the case, but it is unrelated to the lock. If the error mentions something about the lock, then that is your issue, but if the error message mentions checksums, then that is the issue. 

In all cases, when asking for help, including the error message makes it easier to provide assistance.

So, if you are having issues with the checksums, the first thing to remember is that after a changeset is deployed to a database, you should never change that changeset in the changelog again, unless you want to get into a manual fix process. If you deploy a changeset to a database, and then discover that there is something wrong with that changeset, your options are either to roll back that changeset in all environments where it has been deployed, alter the changeset, and then re-deploy, or else write a new changeset that fixes the issue with the first changeset. 

It sounds like you think there are checksum issues, but make sure that is the case before moving forward. 

You can use the clearChecksums command, but that is kind of like pulling the ejection seat. What that does is update every row in the databasechangelog table, setting the md5sum column to null. If you do an update after, it will re-save the checksums of all ran changeSets AND run any new changeSets like normal. The big edge-case that can trip people up is that since the checksum logic is disabled, any previously ran changeSets with runOnChange=true will NOT be re-run.

It also sounds like you have other issues - people hvae changed the ddatabase manually, and now the changelog doesn't match the actual state of the database. In that case, you should be able to use the diffChangelog command to compare two databases (one that has NOT been manually modified and one that has) and add any necessary changes to your changelog, which you can then mark as 'deployed' in the manually modified database using the changeLogSync command. 

If you have any further questions, please reply here with more details and I'll do my best to help.

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

Re : 3.8.5-local-SNAPSHOT instead of 3.8.5 from https://github.com/liquibase/liquibase/releases/tag/v3.8.5

$
0
0
I'm not 100% clear what you are asking here. 

I think you want to build locally, but have that build not be marked as a local build. If that is what you want, you will need to override the settings in the POM by supplying them on the command line like so:

      mvn -Dliquibase.version=3.8.5 clean package

Just curious if there is a reason you can't use the jar as-built?

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

loadupdatedata behavior for mysql

$
0
0
I have changeset to loading a csv to the database. I am using loadUpdateData tag so that any changes to the csv are handled automatically without having to write a new changeset. In the loadUpdateData, i specify the "primaryKey" field, which is different from the actual primary key on the table. This works fine for oracle, but fails for mysql.

My changeset looks like this
  1. <changeSet author ="abc" id="db-1" runAlways="true">
  2.     <loadUpdateData primaryKey="Col10" tablename="someTable" file="changelog/someTable.csv">
  3.       <column name="Col2" type="DATE"/>
  4.       .
  5.       .
  6.      </loadUpdateData>
  7. </changeSet>

The primary key on the table "someTable" is a column named "Col1" which is auto-generated

The oracle generated sql file is
  1. DECLARE
  2. v_reccount NUMBER := 0;
  3. BEGIN
  4. SELECT COUNT(*) INTO v_reccount FROM someTable WHERE FIELDNAME = 'Col10';
  5. IF v_reccount = 0 THEN
  6. INSERT INTO someTable (...) VALUES (...);
  7. ELSIF v_reccount = 1 THEN
  8. UPDATE someTable SET Col2="31-DEC-2019" WHERE FIELDNAME = 'Col10';
  9. END IF;
  10. END;
  11. /
However, the one generated for mysql looks like 
  1. INSERT INTO someTable () VALUES ()
  2. ON DUPLICATE KEY Col2=..., Col3=...;

So, why does the mysql generated statement assume that I want to update data based on the primary key defined in the table, not the column name provided in the primaryKey parameter in the changeSet?

Unexpected error running Liquibase: java.lang.RuntimeException: java.lang.NullPointerException

$
0
0
Hello.

I been unable to use liqubase, it throws this java.lang.NullPointerException error when used, it is a big DB with 836 tables so that maybe has something to do with it.

  1. END)  AS referencing_name from dependency_pair where REFERENCED_NAME != REFERENCING_NAME  AND ( REFERENCED_NAME like 'public.%' OR REFERENCED_NAME NOT LIKE '%.%')  AND referencing_schema_name is not null and referencing_name is not null
  2. 16:35:18.373 ERROR [liquibase.integration.commandline.Main]: Unexpected error running Liquibase: java.lang.RuntimeException: java.lang.NullPointerException
  3. liquibase.exception.LiquibaseException: liquibase.command.CommandExecutionException: java.lang.RuntimeException: java.lang.NullPointerException
  4. at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:284)
  5. at liquibase.integration.commandline.Main.doMigration(Main.java:1317)
  6. at liquibase.integration.commandline.Main.run(Main.java:279)
  7. at liquibase.integration.commandline.Main.main(Main.java:157)
  8. Caused by: liquibase.command.CommandExecutionException: java.lang.RuntimeException: java.lang.NullPointerException
  9. at liquibase.command.AbstractCommand.execute(AbstractCommand.java:24)
  10. at liquibase.integration.commandline.CommandLineUtils.doGenerateChangeLog(CommandLineUtils.java:282)
  11. ... 3 common frames omitted
  12. Caused by: java.lang.RuntimeException: java.lang.NullPointerException
  13. at liquibase.diff.output.changelog.DiffToChangeLog$1.run(DiffToChangeLog.java:178)
  14. at liquibase.Scope.child(Scope.java:101)
  15. at liquibase.Scope.child(Scope.java:82)
  16. at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:121)
  17. at liquibase.diff.output.changelog.DiffToChangeLog.print(DiffToChangeLog.java:88)
  18. at liquibase.command.core.GenerateChangeLogCommand.run(GenerateChangeLogCommand.java:69)
  19. at liquibase.command.AbstractCommand.execute(AbstractCommand.java:19)
  20. ... 4 common frames omitted
  21. Caused by: java.lang.NullPointerException: null
  22. at liquibase.diff.output.changelog.DiffToChangeLog.addDependencies(DiffToChangeLog.java:637)
  23. at liquibase.diff.output.changelog.DiffToChangeLog.sortObjects(DiffToChangeLog.java:369)
  24. at liquibase.diff.output.changelog.DiffToChangeLog.sortMissingObjects(DiffToChangeLog.java:337)
  25. at liquibase.diff.output.changelog.DiffToChangeLog.generateChangeSets(DiffToChangeLog.java:278)
  26. at liquibase.diff.output.changelog.DiffToChangeLog.printNew(DiffToChangeLog.java:205)
  27. at liquibase.diff.output.changelog.DiffToChangeLog$1.run(DiffToChangeLog.java:127)
  28. ... 10 common frames omitted
Thanks

liquibase 3.8.5 needs a pro license key

$
0
0
Hello,

I just update from liquibase 3.6.3 to 3.8.5 and now starts complaining about a missing "Liquibase Pro license"

  1. Failed to execute goal org.liquibase:liquibase-maven-plugin:3.8.5:status (default-cli) on project docs-schema: Error setting up or running Liquibase: Validation Failed:
  2.      11 changes have validation failures
  3.           Change Set ID: 4 Change Set Author: fsousa
  4. Change Type 'pro:createTrigger' is not allowed without a valid Liquibase Pro License.
  5. To purchase or renew a Liquibase Pro license key please contact lbprosales@datical.com or
  6. go to https://download.liquibase.org/liquibase-pro-pricing-details, pt/ipb/gdoc2/schema/categoria.xml::4::fsousa
I don't have an pro:createTrigger but I have a ora:createTrigger that comes from oracle org.liquibase.ext:liquibase-oracle:3.2

  1. <changeSet id="4" author="fsousa">
  2.     <ora:createTrigger
  3.         triggerName="categoria_id"
  4.         afterBeforeInsteadOf="before"
  5.         insert="true"
  6.         tableName="categoria"
  7.         forEachRow="true"
  8.         procedure="
  9.     BEGIN
  10.       IF inserting THEN
  11.         IF :new.categoria_id is null THEN
  12.           SELECT categoria_id.nextval into :NEW.categoria_id from dual;
  13.         END IF;
  14.       END if;
  15.     END;"/>
  16.   </changeSet>

Am I missing something?

Thanks.

Re : liquibase 3.8.5 needs a pro license key

$
0
0
That is not a setup that we tested, and that is not something that we want to have happen. I will create a tracking ticket for this and we will get this fixed as soon as possible. 

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

Re : Unexpected error running Liquibase: java.lang.RuntimeException: java.lang.NullPointerException

$
0
0
I'll take a look - what version of liquibase are you using? What database? It appears you are running the generateChangelog command - is that correct?

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

Re : Unexpected error running Liquibase: java.lang.RuntimeException: java.lang.NullPointerException

$
0
0
Looking at the stack trace, I see "REFERENCED_NAME like 'public.%' " so I am guessing the database is PostgreSQL. 

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

script not executed but added to databasechangelog table

$
0
0
Recently I encountered a case where some liquibase scripts were not executed on a mssql database.

In the databasechangelog table of the database the scripts are marked as executed, however the changes to the schema were not made.

Sadly, logs of the execution are not available because it was reported late and the logs were already auto-deleted.

one of the .xml in question is 00000008_V3.2.1.5_3592#DropCommentsColumnInQualityValue.xml
```<?xml version="1.0" encoding="UTF-8"?>
                   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <changeSet author="faf" id="30.10.19-11:28">
        <dropColumn tableName="QUALITY_VALUE" columnName="COMMENTS"/>
    </changeSet>
</databaseChangeLog>
```

The master.xml contains the script above
```<?xml version="1.0" encoding="utf-8"?>
<databaseChangeLog
   <include file=...
   ...
   <include file="db/changelog/00000008_V3.2.1.5_3592#DropCommentsColumnInQualityValue.xml" relativeToChangelogFile="false"/>
   ...
   ...
</databaseChangeLog>
```

Re : Manually updated sql, how to sync databasechangelog table (md5). ClearCheckSums & gradle ?

$
0
0
Sorry for the delay. It would be nice not to be in place, where there has not been any manual updates to database and changes to changeset. But that is where I'm currently. 
I've checked the logs and yes, there is failing because the checksums dont match, message in the log 'ValidationFailedException: Validation Failed:  1 change sets check sum... classpath.... but is now..." 
 
How can I get that into sync, without building the environment from scratch? Like can I mark/comment/add something to the changesets so that liquibase understands to update checksums and open the locks, without losing the data?


Just noticed, that there are also the correct checksums on the log, could I just update those to the database for the checksums?

By manual database changes, I mean things that should have done by liquibase changescripts are done directly to database (so there is no another database where to diff) and these changes are updated to changesets (so the checksums are incorrect). I know this is not the way things should be done, but this is about getting it back into working state (correct checksums and open locks).

Re : Unexpected error running Liquibase: java.lang.RuntimeException: java.lang.NullPointerException

$
0
0
Postgres 9.6, liquibase 3.8.5; running this command on local database

  1. /liquibase --driver=org.postgresql.Driver --classpath=./postgresql-9.4.1211.jre6.jar --url="jdbc:postgresql://localhost:5432/BBLEARN_GIT" --changeLogFile=db.changelog-1.0.xml --username=postgres --password=postgres --logLevel=DEBUG  generateChangeLog
Viewing all 1169 articles
Browse latest View live


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