changeset 121:720d65bbba13

Extended db scheme to cope with collections, collection items and users. artifacts/trunk@1344 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 01 Mar 2011 16:26:27 +0000
parents c030895edfcb
children c9cf5f33a230
files ChangeLog artifact-database/doc/schema-h2.sql artifact-database/doc/schema-pg.sql
diffstat 3 files changed, 66 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Tue Mar 01 16:07:25 2011 +0000
+++ b/ChangeLog	Tue Mar 01 16:26:27 2011 +0000
@@ -1,3 +1,9 @@
+2011-03-01	Sascha L. Teichmann <sascha.teichmann@intevation.de>
+
+	* artifact-database/doc/schema-pg.sql,
+	  artifact-database/doc/schema-h2.sql: Extended db scheme to
+	  cope with collections, collection items and users.
+
 2011-03-01	Sascha L. Teichmann <sascha.teichmann@intevation.de>
 
 	* artifacts/src/main/java/de/intevation/artifacts/ArtifactFactory.java:
--- a/artifact-database/doc/schema-h2.sql	Tue Mar 01 16:07:25 2011 +0000
+++ b/artifact-database/doc/schema-h2.sql	Tue Mar 01 16:26:27 2011 +0000
@@ -18,4 +18,34 @@
     data        BINARY
 );
 
+CREATE SEQUENCE USERS_ID_SEQ;
+
+CREATE TABLE users (
+    id   INT PRIMARY KEY NOT NULL,
+    gid  UUID            NOT NULL,
+    name VARCHAR(256)    NOT NULL UNIQUE,
+    role BINARY
+);
+
+CREATE SEQUENCE COLLECTIONS_ID_SEQ;
+
+CREATE TABLE collections (
+    id          INT PRIMARY KEY NOT NULL,
+    gid         UUID            NOT NULL,
+    name VARCHAR(256)           NOT NULL,
+    owner_id    INT             NOT NULL REFERENCES users(id),
+    creation    TIMESTAMP       NOT NULL,
+    last_access TIMESTAMP       NOT NULL,
+    ttl         BIGINT, -- NULL means eternal
+);
+
+CREATE SEQUENCE COLLECTION_ITEMS_SEQ;
+
+CREATE TABLE collection_items (
+    id            INT PRIMARY KEY NOT NULL,
+    collection_id INT             NOT NULL REFERENCES collections(id),
+    artifact_id   INT             NOT NULL REFERENCES artifacts(id),
+    UNIQUE (collection_id, artifact_id)
+);
+
 COMMIT;
--- a/artifact-database/doc/schema-pg.sql	Tue Mar 01 16:07:25 2011 +0000
+++ b/artifact-database/doc/schema-pg.sql	Tue Mar 01 16:26:27 2011 +0000
@@ -18,4 +18,34 @@
     data        bytea
 );
 
+CREATE SEQUENCE USERS_ID_SEQ;
+
+CREATE TABLE users (
+    id   int PRIMARY KEY NOT NULL,
+    gid  uuid            NOT NULL,
+    name VARCHAR(256)    NOT NULL UNIQUE,
+    role BINARY
+);
+
+CREATE SEQUENCE COLLECTIONS_ID_SEQ;
+
+CREATE TABLE collections (
+    id          int PRIMARY KEY NOT NULL,
+    gid         uuid            NOT NULL,
+    name VARCHAR(256)           NOT NULL,
+    owner_id    int             NOT NULL REFERENCES users(id),
+    creation    timestamp       NOT NULL,
+    last_access timestamp       NOT NULL,
+    ttl         bigint, -- NULL means eternal
+);
+
+CREATE SEQUENCE COLLECTION_ITEMS_SEQ;
+
+CREATE TABLE collection_items (
+    id            int PRIMARY KEY NOT NULL,
+    collection_id int             NOT NULL REFERENCES collections(id),
+    artifact_id   int             NOT NULL REFERENCES artifacts(id),
+    UNIQUE (collection_id, artifact_id)
+);
+
 COMMIT;

http://dive4elements.wald.intevation.org