summaryrefslogtreecommitdiff
path: root/sql/Pg-database.sql
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-07-12 20:56:23 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-07-12 20:56:23 +0000
commit717349c3e383fae954b39a97f5bea115965f927a (patch)
treed53f63e5a55ed4ff1e87cdfab91ea3fd25b2f8d6 /sql/Pg-database.sql
parentb95fa98fe97fa0ec29ad7d13cc9035c580bd4620 (diff)
Adding partial unique index on partnumber to prevent multiple active items sharing the same part number
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1391 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'sql/Pg-database.sql')
-rw-r--r--sql/Pg-database.sql5
1 files changed, 4 insertions, 1 deletions
diff --git a/sql/Pg-database.sql b/sql/Pg-database.sql
index 3533708e..00d9d86a 100644
--- a/sql/Pg-database.sql
+++ b/sql/Pg-database.sql
@@ -531,6 +531,9 @@ CREATE TABLE parts (
project_id int,
avgcost NUMERIC
);
+
+CREATE UNIQUE INDEX parts_partnumber_index_u ON parts (partnumber)
+WHERE obsolete is false;
--
CREATE TABLE assembly (
id int,
@@ -622,7 +625,7 @@ CREATE TABLE partstax (
chart_id int,
taxcategory_id int,
PRIMARY KEY (parts_id, chart_id),
- FOREIGN KEY (parts_id) REFERENCES parts (id),
+ FOREIGN KEY (parts_id) REFERENCES parts (id) on delete cascade,
FOREIGN KEY (chart_id) REFERENCES chart (id),
FOREIGN KEY (taxcategory_id) REFERENCES taxcategory (taxcategory_id)
);