question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

H2 2.1.210 Table "CONSTRAINTS" not found

See original GitHub issue

Environment

Liquibase Version:

3.10.3

Liquibase Integration & Version: Spring boot 2.4.13

Liquibase Extension(s) & Version: None

Database Vendor & Version: H2 2.1.210

Operating System Type & Version: Ubuntu Linux 21.10

Description

When trying to use H2 2.1.210 Liquibase fails when trying to read the constraints table. It appears in recent H2 versions is it now called table_constraints.

Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "CONSTRAINTS" not found; SQL statement:
select CONSTRAINT_NAME, CONSTRAINT_TYPE, TABLE_NAME from information_schema.constraints where constraint_schema='PUBLIC' and constraint_catalog='74681ECE-17BA-4149-B979-E8C4E193D43F' and constraint_type='UNIQUE' and table_name='DATABASECHANGELOGLOCK' [42102-210]

This appears to be because there is no specific case for H2 in JdbcDatabaseSnapshot.

Steps To Reproduce

List the steps to reproduce the behavior.

  • Update H2 to 2.1.210

Additional Context

Add any other context about the problem here.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
FrostbittenKingcommented, Jul 31, 2022

@nealeu Hi, what is the problem with 4.6.x? I’m about to wrap up migration from 3.8.7!!! to 4.13.0. I ran in quite a few nasty, subtle, deep-rooted bugs, not only this one (which is now luckily easy to fix, cause I worked around all precursor bugs). Had to fix / work around the following bugs:

  • https://github.com/liquibase/liquibase/issues/2385 - the lower case problem with columns like, key, value …)
    • That was a tough one, but it didn’t require too many changes, only locating the cause. This means: use DATABASE_TO_LOWER=true, setting objectQuotingStrategy=QUOTE_ONLY_RESERVED_WORDS, there was one instance of a changeset that required a change too. Unfortunately, this had a property named key and value, and regretably, we wrote them uppercase, so liquibase / h2 ignored the DATABASE_TO_LOWER and it was still added in uppercase, so this needed a change as well. Finally, and most important, corresponding to DATABASE_TO_LOWER…
  • https://forum.liquibase.org/t/schema-drop-fails-after-h2-upgrade-to-2-1-212/6904/3
    • When spring.liquibase.drop-first=true is used in conjunction with DATABASE_TO_LOWER, the bug listed above is triggered. Unfortunately, in this thread the suggested solution doesn’t apply, cause the one suggesting the solution didn’t pay attention what the actual problem was. It was obvious that it’s not the missing chnagelog property. The actual problem was, that when DATABASE_TO_LOWER is used, you need to explicitly set both properties: database-change-log-table and database-change-log-lock-table to lowercase databasechangelog and databasechangeloglock (or else it expects both table names in uppercase, which is wrong due to DATABASE_TO_LOWER).
  • https://github.com/liquibase/liquibase/issues/2396 - the massive logging spam
    • Fix was suggested in the linked bug report in the discussions below
  • https://github.com/liquibase/liquibase/issues/2714 - the checksum bug when deleteCascade=“true” is used in addForeignKeyConstraint (i discovered the cause after debugging the liquibase code, later I found the bug report)
    • Fix was to remove the deleteCascade property (Is this, why you can’t move beyond 4.6.x - actually, this bug hit us with 4.5.0 - I bisected the liquibase libraries to find the start of this bug)
  • https://github.com/liquibase/liquibase/issues/2818 - changelog is found twice in classpath.
    • Fix was to remove the testing files (which did not do much different than the data imports in the regular context)

Maybe this writeup helps you with all the bugs. At least these were the bugs i encounted on the way up to 4.13.0 from 3.8.7.

Finally: If some liquibase dev reads this, maybe it would be useful to start to write up a wiki page where all these bugs are collected with suggested workarounds for other people, so others don’t have to go through all these steps, which partially require a lot of patience and debugging skills. Don’t give up. It takes time.

1reaction
nealeucommented, Jul 31, 2022

@nvoxland Due to https://github.com/liquibase/liquibase/issues/2385, we cannot move to 4.7+. I can’t even validate 4.6.x with H2 2, so it’s really getting quite impossible to move beyond H2 1.x and Liquibase 3.x without a massive rewrite to workaround #2385.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Upgrading H2 database gives constraint not found exception
212 but it gives a constraint not found exception when I try to do so. The SQL is like this: CREATE TABLE itineraries...
Read more >
ErrorCode - H2 Database Engine
The error with code 21002 is thrown when the number of columns does not match. The error with code 90075 is thrown when...
Read more >
Bug #4932: Error in reports after upgrade from H2 1.4.197 to ...
The [*] in the error message indicates the word on which the H2 statement parser had a problem, it is not part of...
Read more >
Newest 'h2' Questions - Stack Overflow
I am learning spring security with JPA auth againest H2 table. ... junit test fails : data jpa query not working with H2...
Read more >
subject:"\[h2\] H2" - The Mail Archive
[h2] H2 version 2.1.210 droping public table on its own ... H2Test$TestTrigger"" not found [90086-196]" I tried several things but i ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found