-
Notifications
You must be signed in to change notification settings - Fork 213
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
Unique key violation on changes.script_hash not handled #630
Comments
Odd, I am not able to replicate this issue. I
Out of curiosity, I diffed a dump of a database where the tag was deployed at the same time as the last change, and another where it was deployed after the last change, as in your example. The only difference was that the Would you mind sharing an example of
|
Hi. Please see this project on how to recreate the issue: |
Thanks for that. This is because there is no change to the deploy script. It works with this change: --- a/test.sh
+++ b/test.sh
@@ -7,4 +7,5 @@ docker exec -ti -u999 sqitch-test bash -c 'cd /tmp/s630/ && sqitch tag myTag -m
docker exec -ti -u999 sqitch-test bash -c 'cd /tmp/s630/ && sqitch deploy'
docker exec -ti -u999 sqitch-test bash -c 'cd /tmp/s630/ && sqitch status'
docker exec -ti -u999 sqitch-test bash -c 'cd /tmp/s630/ && sqitch rework test1 -m "reworking"'
+docker exec -ti -u999 sqitch-test bash -c 'cd /tmp/s630/ && echo >> deploy/test1.sql'
docker exec -ti -u999 sqitch-test bash -c 'cd /tmp/s630/ && sqitch deploy' This is on the assumption that you will change the deploy script — because otherwise why rework it? |
Mean to say thanks a million for taking the time to build such a terrific test case. Made it easy for me to replicate and see what was going on --- even if I did first go down a rabbit hole to install v1.3.1 to make sure the issue remained (I think the apt repo installs v1.1.0). |
So just for me to understand, the issue happens because the hash of the file did not change? |
Right, it creates the script as a copy of the old one, but expects you to modify it — otherwise why bother reworking it if you don't rework it? :-) |
Hi. I found another case that triggers the same error message:
|
I'm not able to replicate that issue, either :-( Here's what I did:
|
Re-opening, because I now realize that the raw SQL error is a bug. The code needs to catch unique key violations and return a more meaningful error. |
I will try to recreate this using the project submitted before, but I need a bit of time. |
Originally added in a04be11 and updated in 4d63e2c, the unique violations have been working fine in most situations, but were confusing when hit, as they returned as raw SQL errors. So modify `log_deploy_change` to catch database exceptions, check for unique constraint violations, and return the more useful error message `Cannot log change "{change}": The deploy script is not unique`. Requires adding a new method to each engine, `_unique_error`, which checks error codes from the DBI to determine whether the most recent error was a unique violation. The default implementation always returns false for the database engines that don't enforce unique constraints (Exasol and Snowflake). Add a test to DBIEngineTest to trigger the unique violation. This required fixing some tests that previously always passed when they shouldn't (thanks to the use of `try` without `catch`) and fixing them to testing things properly. Also requires a new parameter to `DBIEngineTest->run()` to disable the unique constraint test for engines that don't enforce that constraint (Exasol and Snowflake). While at it, always enable primary key and unique constraints on Vertica. They previously were enforced only by database-level configuration, and unique constraints only on Vertica 7.2 and later with that configuration. Enforcement will only be enabled by default for new registry databases. Drop support for versions of Vertica prior to 7.2, which don't support the syntax to enable constraints. Also drop support for versions of SQLite prior to 3.8.6, when unique constraint enforcement was added to SQLite. Resolves #630.
Originally added in a04be11 and updated in 4d63e2c, the unique violations have been working fine in most situations, but were confusing when hit, as they returned as raw SQL errors. So modify `log_deploy_change` to catch database exceptions, check for unique constraint violations, and return the more useful error message `Cannot log change "{change}": The deploy script is not unique`. Requires adding a new method to each engine, `_unique_error`, which checks error codes from the DBI to determine whether the most recent error was a unique violation. The default implementation always returns false for the database engines that don't enforce unique constraints (Exasol and Snowflake). Add a test to DBIEngineTest to trigger the unique violation. This required fixing some tests that previously always passed when they shouldn't (thanks to the use of `try` without `catch`) and fixing them to testing things properly. Also requires a new parameter to `DBIEngineTest->run()` to disable the unique constraint test for engines that don't enforce that constraint (Exasol and Snowflake). While at it, always enable primary key and unique constraints on Vertica. They previously were enforced only by database-level configuration, and unique constraints only on Vertica 7.2 and later with that configuration. Enforcement will only be enabled by default for new registry databases. Drop support for versions of Vertica prior to 7.2, which don't support the syntax to enable constraints. Also drop support for versions of SQLite prior to 3.8.6, when unique constraint enforcement was added to SQLite. Resolves #630.
Hi.
Having an issue when I try to deploy and I am able to recreate it on all our environments.
When I run sqitch deploy I get this error in the database:
The steps I followed to create this problem:
sqitch deploy
without adding any other changessqitch rework
sqitch deploy
again:This is how I worked around this problem:
sqitch revert @HEAD^
The text was updated successfully, but these errors were encountered: