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

Remove implicit definition of unique constraint on SETTING table due to test problems #293

Closed
Fizol opened this issue Dec 4, 2016 · 3 comments
Assignees

Comments

@Fizol
Copy link
Collaborator

Fizol commented Dec 4, 2016

Depending on #291
In Liquibase when you implicitly create unique constraint on column:

<changeSet id="012-create-setting-table" author="Tomasz.Dziurko">
    <createTable tableName="setting">
   (...)
        <column name="name" type="varchar(100)">
            <constraints nullable="false" unique="true"/>
        </column>
   (...)
    </createTable>
</changeSet>

You get

"setting_name_key" UNIQUE CONSTRAINT, btree (name)

But against H2

select constraint_name from information_schema.constraints where table_name='METADATA' and column_list='NAME';
=> CONSTRAINT_A

This gives suprising effects (exception) when you run test with spring boot context and H2 and previously renamed constraint on tables.

Task is to remove this implicit definition and do explicit definition modyfing old changest ("012-create-setting-table"), and in the future define unique constraint names only using 'addUniqueConstraint'.

@tdziurko
Copy link
Collaborator

tdziurko commented Dec 4, 2016

Ok, this sounds reasonable and if you want you can fix it so application (or database) behaves more predictably. But I see one major problem: you can not modify already applied changesets, you need to write a new changeset that fixes these problems.

Also (as an extra) I would:

  • add info about this convention in naming constraints to our guidelines
  • consider adding a check that fails a build when someone do not obey this rule. This might be tricky to accomplish though :)

@tdziurko
Copy link
Collaborator

@Fizol What is the status of this issue? I am not sure if it is 100% complete or not :)

@Fizol
Copy link
Collaborator Author

Fizol commented Aug 28, 2017

@tdziurko Please let me check that.
As I remember I was waiting for #295 to be merged, and after waiting almost 2 months I lost my all hopes. Than you merged that, but hopes were gone :)

@tdziurko tdziurko closed this as completed Dec 2, 2017
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

2 participants