-
Notifications
You must be signed in to change notification settings - Fork 34
fix remove unique constraint for collection_series. #1124
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
fix remove unique constraint for collection_series. #1124
Conversation
Generated by 🚫 Danger |
On my local pc, alter table Error on rename of '.\mystamps#sql-c38_6' to '.\mystamps\collections_series' (errno: 150 - Foreign key constraint is incorrectly formed) |
45258c6
to
8de6358
Compare
Alter table MysqlError #1025 |
|
||
<changeSet author="mukeshk" id="drop-unique-constraint-from-collections_series-table"> | ||
<comment>Remove unique constraint (collection_id,series_id) from collection_series</comment> | ||
<dropForeignKeyConstraint baseTableName="collections_series" constraintName="fk_collections_series_series_id" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's counter intuitive that we remove and re-create foreign keys. Is it required? Would dropUniqueConstraint
work without it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would dropUniqueConstraint work without it?
I've just tested it locally (with H2) and it works. So, it's not clear so far why you've added it as it's unnecessary.
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd"> | ||
|
||
<changeSet author="mukeshk" id="drop-unique-constraint-from-collections_series-table"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typically "id" come first and also "context" attribute is missing here.
Ok, I'll look on this failure later. |
<changeSet author="mukeshk" id="drop-unique-constraint-from-collections_series-table"> | ||
<comment>Remove unique constraint (collection_id,series_id) from collection_series</comment> | ||
<dropForeignKeyConstraint baseTableName="collections_series" constraintName="fk_collections_series_series_id" /> | ||
<dropUniqueConstraint constraintName="uc_collections_series_collection_id_series_id" tableName="collections_series"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line has trailing space BTW.
<comment>Remove unique constraint (collection_id,series_id) from collection_series</comment> | ||
<dropForeignKeyConstraint baseTableName="collections_series" constraintName="fk_collections_series_series_id" /> | ||
<dropUniqueConstraint constraintName="uc_collections_series_collection_id_series_id" tableName="collections_series"/> | ||
<addForeignKeyConstraint baseTableName="collections_series" baseColumnNames="series_id" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line has trailing space BTW.
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd"> | ||
|
||
<changeSet author="mukeshk" id="drop-unique-constraint-from-collections_series-table"> | ||
<comment>Remove unique constraint (collection_id,series_id) from collection_series</comment> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather remove this comment as it looks obvious to me.
Yes. The drop unique constraint worked on H2 db. But Travis failed for MySQL
I will push again so that you will notice in Travis.
Thanks
…On Sat 21 Sep, 2019, 8:39 PM Slava Semushin, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
src/main/resources/liquibase/version/0.4.1/2019-09-18--rollback_collection_unique_series_constraint.xml
<#1124 (comment)>:
> @@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<databaseChangeLog
+ xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog
+ http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd">
+
+ <changeSet author="mukeshk" id="drop-unique-constraint-from-collections_series-table">
+ <comment>Remove unique constraint (collection_id,series_id) from collection_series</comment>
+ <dropForeignKeyConstraint baseTableName="collections_series" constraintName="fk_collections_series_series_id" />
Would dropUniqueConstraint work without it?
I've just tested it locally (with H2) and it works. So, it's not clear so
far why you've added it as it's unnecessary.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1124?email_source=notifications&email_token=AAJPE6EHOK2C7TCOZLDXDYLQKY2MNA5CNFSM4IY4PST2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCFPXMGQ#discussion_r326863208>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJPE6C2LD3L5A2JR57GYLTQKY2MNANCNFSM4IY4PSTQ>
.
|
8de6358
to
43ae664
Compare
I'll look on this but anyway it should be noted in the comments. Mostly anything that we solve in a unexpected way because of the obstacles, should be expressed in the comments.
JFYI: I don't get notified on your builds. So the only way to see is when you push to this PR and I look on the result manualy. |
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd"> | ||
|
||
<changeSet author="mukeshk" id="drop-unique-constraint-from-collections_series-table"> | ||
<dropUniqueConstraint constraintName="uc_collections_series_collection_id_series_id" tableName="collections_series"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are 2 spaces before "tableName" attribute :)
I'm a little confused why it uses
I wouldn't surprise if that's a liquibase bug, for instance. |
Both are failing in this case :(
|
I found an advise (see https://dba.stackexchange.com/questions/190153/mysql-create-table-error-1005-errno-150-foreign-key-constraint-is-incorrectly/201950#201950) to use
After closer look on the table definition I see the following:
Note that we have
So, it seems like we should add this key then before dropping an unique constraint. I'll check how it works in H2 later to confirm whether it's right way to go. |
It looks like H2 has 2 indices already and it was MySQL trick to optimize number of indices. So, I suggest to: before dropping a unique index, first create an index for collection_id column. It will be a separate changeset I think. If this operation fails on H2, then we should execute it only on MySQL (with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comments.
It seems I messed up with my branch. it created a detached head.
Any idea what i can do to fix this? sorry for the trouble. |
If you only need to reset master to be even with origin/master, use |
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog | ||
http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.0.xsd"> | ||
|
||
<changeSet author="mukeshk" id="create-index-seriesid-on-collections-series-table"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put 2 change sets to a single file.
No, there shouldn't be my commits, only yours :) |
0e1b9c2
to
f3c2518
Compare
BTW for a new PR -- don't forget to move a file with migration to 0.4.2 folder as 0.4.1 milestone is closed. |
Fix #986