[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SF.net SVN: ledger-smb: [1261] trunk/sql/Pg-database.sql



Revision: 1261
          http://svn.sourceforge.net/ledger-smb/?rev=1261&view=rev
Author:   linuxpoet
Date:     2007-06-10 08:56:40 -0700 (Sun, 10 Jun 2007)

Log Message:
-----------
added referential mapping for notes

Modified Paths:
--------------
    trunk/sql/Pg-database.sql

Modified: trunk/sql/Pg-database.sql
===================================================================
--- trunk/sql/Pg-database.sql	2007-06-07 04:18:40 UTC (rev 1260)
+++ trunk/sql/Pg-database.sql	2007-06-10 15:56:40 UTC (rev 1261)
@@ -25,7 +25,6 @@
 
 CREATE index entity_class_idx ON entity_class(lower(class));
 
-COMMENT ON INDEX entity_class_unique_idx IS $$ Helps truly define unique. Which we could do that with Primary Keys $$;
 
 ALTER TABLE entity ADD FOREIGN KEY (entity_class) REFERENCES entity_class(id);
 
@@ -198,10 +197,12 @@
 
 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 timestamp not null default now(),
+                   ref_key integer not null);
 
 CREATE TABLE entity_note() INHERITS (note);
 ALTER TABLE entity_note ADD CHECK (id = 1);
+ALTER TABLE entity_note ADD FOREIGN KEY (ref_key) REFERENCES entity(id);
 CREATE INDEX entity_note_id_idx ON entity_note(id);
 CREATE UNIQUE INDEX entity_note_class_idx ON note_class(lower(class));
 CREATE INDEX entity_note_vectors_idx ON entity_note USING gist(vector);
@@ -309,7 +310,13 @@
   serialnumber text,
   notes text
 );
+
+-- Added for Entity but can't be added due to order
+ALTER TABLE invoice_note ADD FOREIGN KEY (ref_key) REFERENCES invoice(id);
+
 --
+
+--
 CREATE TABLE customer (
   id serial PRIMARY KEY,
   entity_id int references entity(id),


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.