rename table 'sfa' into 'records' and add constraints on types
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 1 Dec 2011 17:45:35 +0000 (18:45 +0100)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 1 Dec 2011 17:45:35 +0000 (18:45 +0100)
sfa/storage/sfa.sql
sfa/storage/table.py

index 3d7984d..202b91f 100644 (file)
@@ -36,14 +36,27 @@ CREATE AGGREGATE array_accum (
     initcond = '{}'
 );
 
+-- Valid record types
+CREATE TABLE record_types (
+       record_type text PRIMARY KEY
+) WITH OIDS;
+INSERT INTO record_types (record_type) VALUES ('authority');
+INSERT INTO record_types (record_type) VALUES ('authority+sa');
+INSERT INTO record_types (record_type) VALUES ('authority+am');
+INSERT INTO record_types (record_type) VALUES ('authority+sm');
+INSERT INTO record_types (record_type) VALUES ('user');
+INSERT INTO record_types (record_type) VALUES ('slice');
+INSERT INTO record_types (record_type) VALUES ('node');
+
+
 -- main table 
-CREATE TABLE sfa ( 
+CREATE TABLE records ( 
     record_id serial PRIMARY KEY , 
     hrn text NOT NULL, 
     authority text NOT NULL, 
     peer_authority text, 
     gid text, 
-    type text NOT NULL
+    type text REFERENCES record_types
     pointer integer, 
     date_created timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP, 
     last_updated timestamp without time zone NOT NULL DEFAULT CURRENT_TIMESTAMP
index acd0b3d..602bcab 100644 (file)
@@ -14,7 +14,7 @@ from sfa.storage.record import SfaRecord, AuthorityRecord, NodeRecord, SliceReco
 
 class SfaTable(list):
 
-    SFA_TABLE_PREFIX = "sfa"
+    SFA_TABLE_PREFIX = "records"
 
     def __init__(self, record_filter = None):