diff options
author | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-12-28 02:40:43 +0000 |
---|---|---|
committer | tetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46> | 2007-12-28 02:40:43 +0000 |
commit | 1250e797afd9a206a1dc579601429c2af91de388 (patch) | |
tree | 92e7491a52a46d73433d1bdc2a616605d71910f2 /sql | |
parent | f6a3a83e348394b45c5e27c7cc89703d5887d9cb (diff) |
Adding a fix script for the primary key to the tax table
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/branches/1.2@2011 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'sql')
-rw-r--r-- | sql/fixes/tax_pkey_duplicate.sql | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/sql/fixes/tax_pkey_duplicate.sql b/sql/fixes/tax_pkey_duplicate.sql new file mode 100644 index 00000000..f590d8ca --- /dev/null +++ b/sql/fixes/tax_pkey_duplicate.sql @@ -0,0 +1,13 @@ +-- SC: Replaces the primary key of the tax table with a check for if the +-- combination of chart_id and validto is unique. An index is added to +-- check for the case of multiple NULL validto values and fail if that would +-- result. + +ALTER TABLE tax DROP CONSTRAINT tax_pkey; +ALTER TABLE tax ADD CONSTRAINT tax_unique UNIQUE (chart_id, validto); +COMMENT ON CONSTRAINT tax_unique ON tax IS +$$Checks on the base uniqueness of the chart_id, validto combination$$; + +CREATE UNIQUE INDEX tax_null_validto_unique_idx ON tax(chart_id) WHERE validto IS NULL; +COMMENT ON INDEX tax_null_validto_unique_idx ON tax IS +$$Part of primary key emulation for the tax table, ensures at most one NULL validto for each chart_id$$; |