-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Unique key constraint cannot be added #15
Comments
Documentation for pt-osc: https://www.percona.com/doc/percona-toolkit/LATEST/pt-online-schema-change.html#id7 Seems like we simply need to add this flag ( I think, this option is new with percona toolkit 3.0 |
@paulozenida You can set these properties by using the standard java -D option:
I'm working on a fix for the next version of the plugin. |
Hum, I see. At the time being, I had simply added the -Dliquibase.percona.skipChanges=addUniqueConstraint,dropUniqueConstraint to avoid that issue. With the -Dliquibase.percona.options="--nocheck-unique-key-change" both may be "unskipped"? |
Yes, that should work. While upgrading pt-osc to version 3.0.7, I came across an issue with adding self-referencing foreign keys... the two integration tests are failing. |
I'm using pt-osc 3.0.5 and I also had to skip the foreignKeyConstraints from liquibase+percona to make it work. I'm not sure exactly what the problem was but I know I had to skip those two as well: |
Hello, JAVA_OPTS="${JAVA_OPTS-} -Dliquibase.percona.options=--nocheck-unique-key-change -Dliquibase.percona.skipChanges=addForeignKeyConstraint,dropForeignKeyConstraint" but it didn't work so I had to go back to the previous solution and use it like: |
https://jira.percona.com/browse/PT-381 suggest the following fix for the self-referencing foreign keys:
I've added this workaround back then: adangel@21177f1 Unfortunately pt-osc 2.2.21 was never released and the bug seems to be back with pt-osc 3. I'll enable the workaround for PT 3, too. |
For a command to add a unique key constraint such as:
We have a failure message similar to:
"No foreign keys reference
serviceauth
.connection
; ignoring --alter-foreign-keys-method.Altering
serviceauth
.connection
...serviceauth
.connection
was not altered.You are trying to add an unique key. This can result in data loss if the data is not unique.
Please read the documentation for the --check-unique-key-change parameter.
You can check if the column(s) contain duplicate content by running this/these query/queries:
SELECT IF(COUNT(DISTINCT user_credentials_id) = COUNT(*),
'Yes, the desired unique index currently contains only unique values',
'No, the desired unique index contains duplicated values. There will be data loss'
) AS IsThereUniqueness FROM
serviceauth
.connection
;Keep in mind that these queries could take a long time and consume a lot of resources"
Adding the flag --nocheck-unique-key-change to the generated command, however, allows it to be successfully ran.
The text was updated successfully, but these errors were encountered: