summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-08-22 05:28:47 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2008-08-22 05:28:47 +0000
commit3e05015f9995f2f11556be0f8b6a73051d7d7def (patch)
tree068fa8f6cf234494b5536dbec65ea16be166288f /sql
parent9dde8344f2004346a0b8db1f764d3c998c555391 (diff)
Correcting load issues with Pg-database.sql
Also adding NOT NULL constraints to ar.entity_credit_account and ap.entity_credit_account git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@2299 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'sql')
-rw-r--r--sql/Pg-database.sql22
1 files changed, 11 insertions, 11 deletions
diff --git a/sql/Pg-database.sql b/sql/Pg-database.sql
index 03b4afb5..4648f535 100644
--- a/sql/Pg-database.sql
+++ b/sql/Pg-database.sql
@@ -293,6 +293,15 @@ CREATE TABLE company_to_contact (
COMMENT ON TABLE company_to_contact IS $$ To keep track of the relationship between multiple contact methods and a single company $$;
+CREATE TABLE entity_bank_account (
+ id serial not null,
+ entity_id int not null references entity(id) ON DELETE CASCADE,
+ bic varchar,
+ iban varchar,
+ UNIQUE (id),
+ PRIMARY KEY (entity_id, bic, iban)
+);
+
CREATE TABLE entity_credit_account (
id serial not null unique,
entity_id int not null references entity(id) ON DELETE CASCADE,
@@ -364,7 +373,7 @@ CREATE UNIQUE INDEX note_class_idx ON note_class(lower(class));
CREATE TABLE note (id serial primary key, note_class integer not null references note_class(id),
note text not null, vector tsvector not null,
created timestamp not null default now(),
- created_by text DEFAULT SESSION_USER;
+ created_by text DEFAULT SESSION_USER,
ref_key integer not null);
CREATE TABLE entity_note(entity_id int references entity(id)) INHERITS (note);
@@ -589,15 +598,6 @@ create view employee as
*/
-CREATE TABLE entity_bank_account (
- id serial not null,
- entity_id int not null references entity(id) ON DELETE CASCADE,
- bic varchar,
- iban varchar,
- UNIQUE (id),
- PRIMARY KEY (entity_id, bic, iban)
-);
-
CREATE VIEW customer AS
SELECT
c.id,
@@ -777,7 +777,7 @@ CREATE TABLE ap (
terms int2 DEFAULT 0,
description text,
force_closed bool,
- entity_credit_account int references entity_credit_account(id)
+ entity_credit_account int references entity_credit_account(id) NOT NULL
);
COMMENT ON COLUMN ap.entity_id IS $$ Used to be customer_id, but customer is now metadata. You need to push to entity $$;