summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorlinuxpoet <linuxpoet@4979c152-3d1c-0410-bac9-87ea11338e46>2007-06-05 03:48:30 +0000
committerlinuxpoet <linuxpoet@4979c152-3d1c-0410-bac9-87ea11338e46>2007-06-05 03:48:30 +0000
commit2bc4e652903d4af47952c4d53db538bb5d802343 (patch)
treec3977311e2a450996797837080d4be32544a5a5e /sql
parent501ac60d3a4a6d438ba93495d6be379afc5ec44a (diff)
added created columns for person, company and entity
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1256 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'sql')
-rw-r--r--sql/Pg-database.sql8
1 files changed, 5 insertions, 3 deletions
diff --git a/sql/Pg-database.sql b/sql/Pg-database.sql
index e783a946..a599c3ad 100644
--- a/sql/Pg-database.sql
+++ b/sql/Pg-database.sql
@@ -9,7 +9,8 @@ CREATE TABLE transactions (
CREATE TABLE entity (
id serial PRIMARY KEY,
name text check (name ~ '[[:alnum:]_]'),
- entity_class integer not null);
+ entity_class integer not null,
+ created date not null default current_date);
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 $$;
@@ -69,7 +70,6 @@ INSERT INTO location_class(id,class,authoritative) VALUES ('3','Shipping',TRUE);
SELECT SETVAL('location_class_id_seq',4);
-
CREATE TABLE location (
id serial PRIMARY KEY,
location_class integer not null references location(id),
@@ -87,6 +87,7 @@ CREATE TABLE company (
entity_id integer not null references entity(id),
legal_name text check (legal_name ~ '[[:alnum:]_]'),
tax_id text,
+ created date default current_date not null,
PRIMARY KEY (entity_id,legal_name));
COMMENT ON COLUMN company.tax_id IS $$ In the US this would be a EIN. $$;
@@ -116,7 +117,8 @@ CREATE TABLE person (
salutation_id integer references salutation(id),
first_name text check (first_name ~ '[[:alnum:]_]') NOT NULL,
middle_name text,
- last_name text check (last_name ~ '[[:alnum:]_]') NOT NULL
+ last_name text check (last_name ~ '[[:alnum:]_]') NOT NULL,
+ created date not null default current_date
);
COMMENT ON TABLE person IS $$ Every person, must have an entity to derive a common or display name. The correct way to get class information on a person would be person.entity_id->entity_class_to_entity.entity_id. $$;