From 3e05015f9995f2f11556be0f8b6a73051d7d7def Mon Sep 17 00:00:00 2001 From: einhverfr Date: Fri, 22 Aug 2008 05:28:47 +0000 Subject: 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 --- sql/Pg-database.sql | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'sql') 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 $$; -- cgit v1.2.3