Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UniqueConstaintExistsPrecondition ignores liquibaseSchema property #5907

Closed
2 tasks done
bostandyksoft opened this issue May 14, 2024 · 8 comments
Closed
2 tasks done

Comments

@bostandyksoft
Copy link

bostandyksoft commented May 14, 2024

Search first

  • I searched and no similar issues were found

Description

Our Postgres instance database several schemas with same structure, so there are many objects with same name in different schemas.
I found, that when UniquieConstraintExistsPrecondition performs search constraint, it dont use liquibaseSchema property to strict query to found objects only in working schema.
I'm not sure about other preconditions, but it looks like that DatabaseSnapshot dont use this property at all

PS I've researched TableExistsPrecondition. DatabaseSnapshot also dont use this propery. But somewhere SnapshotGenerator adds restriction on

FROM pg_catalog.pg_namespace n
...
WHERE ... n.nspname LIKE '<my_scheme>'

Steps To Reproduce

Initialize Postgres database with 2 schemas.
One schema contains uniqueconstraint, another does not contain.
Roll changeset with UniqueConstaintExistsPrecondition

Expected/Desired Behavior

UniqueConstaintExistsPrecondition ignores uniqueconstraint from another schema

Liquibase Version

4.27.0

Database Vendor & Version

Postgres 12.5

Liquibase Integration

spring boot

Liquibase Extensions

No response

OS and/or Infrastructure Type/Provider

No response

Additional Context

No response

Are you willing to submit a PR?

  • I'm willing to submit a PR (Thank you!)
@bostandyksoft
Copy link
Author

I'm not sure - send me please a link to manual for PR. I've found that there is need to add following code to UniqueConstraintSnapshotGenerator

CatalogAndSchema catalogAndSchema = new CatalogAndSchema(schema.getCatalogName(), schema.getSchema().getName()).customize(database)

to line 146 and use this object to build query below

@kevin-atx
Copy link
Contributor

Here are the instructions for submitting a PR - https://contribute.liquibase.com/code/get-started/create-pr/.

Let us know if you have any other questions. Thanks for the PR!

@mpvvliet
Copy link
Contributor

I've recently contributed a fix in #5783 which looks like it might fix this issue in another way.

@bostandyksoft
Copy link
Author

I've recently contributed a fix in #5783 which looks like it might fix this issue in another way.

Hi. Yes you are right, it looks like this PR should help.

@kevin-atx
Copy link
Contributor

kevin-atx commented May 16, 2024

@bostandyksoft@mpvvliet's fix has been merged and was released on May 21, 2024 as Liquibase version 4.28.0. Please test to see if the fix addresses your issue and let us know.

@kevin-atx
Copy link
Contributor

@bostandyksoft and @mpvvliet - have either of you had a chance to test Liquibase 4.28.0 to see if it addresses the issues you were having?

@bostandyksoft
Copy link
Author

@bostandyksoft and @mpvvliet - have either of you had a chance to test Liquibase 4.28.0 to see if it addresses the issues you were having?

I've checked it now - it is working now correctly. I saw all of my lost unique constraints

@kevin-atx
Copy link
Contributor

That's great news. I'll close this ticket as fixed. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants