From 705cd6e99995e16036e606cb81ee729f8279a80d Mon Sep 17 00:00:00 2001 From: linuxpoet Date: Thu, 9 Aug 2007 20:08:36 +0000 Subject: fixed primary key for entity git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1455 4979c152-3d1c-0410-bac9-87ea11338e46 --- sql/Pg-database.sql | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'sql/Pg-database.sql') diff --git a/sql/Pg-database.sql b/sql/Pg-database.sql index 8011a9b8..57594e4a 100644 --- a/sql/Pg-database.sql +++ b/sql/Pg-database.sql @@ -112,13 +112,12 @@ batch work flows. $$; -- BEGIN new entity management CREATE TABLE entity ( - id serial PRIMARY KEY, + id serial UNIQUE, name text check (name ~ '[[:alnum:]_]'), entity_class integer not null, - created date not null default current_date); + created date not null default current_date, + PRIMARY KEY(name,entity_class)); -CREATE UNIQUE INDEX entity_class_name_class_idx ON entity(name,entity_class); - COMMENT ON TABLE entity IS $$ The primary entity table to map to all contacts $$; COMMENT ON COLUMN entity.name IS $$ This is the common name of an entity. If it was a person it may be Joshua Drake, a company Acme Corp. You may also choose to use a domain such as commandprompt.com $$; @@ -323,10 +322,6 @@ CREATE INDEX invoice_note_id_idx ON invoice_note(id); CREATE UNIQUE INDEX invoice_note_class_idx ON note_class(lower(class)); CREATE INDEX invoice_note_vectors_idx ON invoice_note USING gist(vector); --- is this safe? -ALTER TABLE invoice_note ADD CHECK (id = 2); - - -- END entity -- -- cgit v1.2.3