-
Notifications
You must be signed in to change notification settings - Fork 214
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Catch script_hash unique constraint violations
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.
- Loading branch information
Showing
23 changed files
with
200 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
ALTER TABLE :"registry".changes DROP CONSTRAINT c_unique; | ||
ALTER TABLE :"registry".changes ADD UNIQUE(project, script_hash); | ||
ALTER TABLE :"registry".changes ADD UNIQUE(project, script_hash) ENABLED; | ||
COMMENT ON SCHEMA :"registry" IS 'Sqitch database deployment metadata v1.1.'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.