# HG changeset patch # User Andre Heinecke # Date 1363103447 -3600 # Node ID 3ba2917e49d387a3d5123e7df0f20be0729965a8 # Parent 9c4e2192810c683039999616374bcc6c7a834854 Remove old artifacts-h2.sql and datacage.sql and expect the path to the database scheme as a parameter in the scripts diff -r 9c4e2192810c -r 3ba2917e49d3 contrib/make_flys_release/h2/artifacts-h2.sql --- a/contrib/make_flys_release/h2/artifacts-h2.sql Tue Mar 12 16:49:16 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,59 +0,0 @@ --- --- schema to store artifacts in H2 databases. --- - -BEGIN; - --- not using AUTO_INCREMENT to be more compatible with --- other dbms. -CREATE SEQUENCE ARTIFACTS_ID_SEQ; - -CREATE TABLE artifacts ( - id INT PRIMARY KEY NOT NULL, - gid UUID NOT NULL UNIQUE, - creation TIMESTAMP NOT NULL, - last_access TIMESTAMP NOT NULL, - ttl BIGINT, -- NULL means eternal - factory VARCHAR(256) NOT NULL, - data BINARY -); - -CREATE SEQUENCE USERS_ID_SEQ; - -CREATE TABLE users ( - id INT PRIMARY KEY NOT NULL, - gid UUID NOT NULL UNIQUE, - name VARCHAR(256) NOT NULL, - account 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 UNIQUE, - 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 - attribute BINARY -); - -CREATE SEQUENCE COLLECTION_ITEMS_ID_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), - attribute BINARY, - creation TIMESTAMP NOT NULL, - UNIQUE (collection_id, artifact_id) -); - -CREATE TRIGGER collections_access_update_trigger AFTER UPDATE - ON artifacts FOR EACH ROW - CALL "de.intevation.artifactdatabase.h2.CollectionAccessUpdateTrigger"; - -COMMIT; diff -r 9c4e2192810c -r 3ba2917e49d3 contrib/make_flys_release/h2/createArtifacts.sh --- a/contrib/make_flys_release/h2/createArtifacts.sh Tue Mar 12 16:49:16 2013 +0100 +++ b/contrib/make_flys_release/h2/createArtifacts.sh Tue Mar 12 16:50:47 2013 +0100 @@ -1,6 +1,6 @@ #!/bin/bash -mkdir artifactsdb +mkdir -p artifactsdb DIR=`dirname $0` DIR=`readlink -f "$DIR"` @@ -12,6 +12,10 @@ export CLASSPATH +if [ $# != 1 ]; then + echo "Usage: $0 " +fi + java org.h2.tools.RunScript \ -url jdbc:h2:`readlink -f artifactsdb`/artifacts \ - -script $DIR/artifacts-h2.sql + -script "$1" diff -r 9c4e2192810c -r 3ba2917e49d3 contrib/make_flys_release/h2/createDatacage.sh --- a/contrib/make_flys_release/h2/createDatacage.sh Tue Mar 12 16:49:16 2013 +0100 +++ b/contrib/make_flys_release/h2/createDatacage.sh Tue Mar 12 16:50:47 2013 +0100 @@ -1,6 +1,6 @@ #!/bin/bash -mkdir datacagedb +mkdir -p datacagedb DIR=`dirname $0` DIR=`readlink -f "$DIR"` @@ -11,7 +11,10 @@ done export CLASSPATH +if [ $# != 1 ]; then + echo "Usage: $0 " +fi java org.h2.tools.RunScript \ -url jdbc:h2:`readlink -f datacagedb`/datacage \ - -script $DIR/datacage.sql + -script "$1" diff -r 9c4e2192810c -r 3ba2917e49d3 contrib/make_flys_release/h2/datacage.sql --- a/contrib/make_flys_release/h2/datacage.sql Tue Mar 12 16:49:16 2013 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,104 +0,0 @@ -BEGIN; - -CREATE SEQUENCE USERS_ID_SEQ; - -CREATE TABLE users ( - id INT PRIMARY KEY NOT NULL, - gid UUID NOT NULL UNIQUE -); - -CREATE SEQUENCE COLLECTIONS_ID_SEQ; - -CREATE TABLE collections ( - id INT PRIMARY KEY NOT NULL, - gid UUID NOT NULL UNIQUE, - user_id INT NOT NULL REFERENCES users(id) ON DELETE CASCADE, - name VARCHAR(256) NOT NULL, - creation TIMESTAMP NOT NULL -); - -CREATE SEQUENCE ARTIFACTS_ID_SEQ; - -CREATE TABLE artifacts ( - id INT PRIMARY KEY NOT NULL, - gid UUID NOT NULL UNIQUE, - state VARCHAR(256) NOT NULL, - creation TIMESTAMP NOT NULL -); - -CREATE SEQUENCE COLLECTION_ITEMS_ID_SEQ; - -CREATE TABLE collection_items ( - id INT PRIMARY KEY NOT NULL, - collection_id INT NOT NULL REFERENCES collections(id) ON DELETE CASCADE, - artifact_id INT NOT NULL REFERENCES artifacts(id) ON DELETE CASCADE -); - -CREATE SEQUENCE ARTIFACT_DATA_ID_SEQ; - -CREATE TABLE artifact_data ( - id INT PRIMARY KEY NOT NULL, - artifact_id INT NOT NULL REFERENCES artifacts(id) ON DELETE CASCADE, - kind VARCHAR(256) NOT NULL, - k VARCHAR(256) NOT NULL, - v VARCHAR(256), -- Maybe too short - UNIQUE (artifact_id, k) -); - -CREATE SEQUENCE OUTS_ID_SEQ; - -CREATE TABLE outs ( - id INT PRIMARY KEY NOT NULL, - artifact_id INT NOT NULL REFERENCES artifacts(id) ON DELETE CASCADE, - name VARCHAR(256) NOT NULL, - description VARCHAR(256), - out_type VARCHAR(256) -); - -CREATE SEQUENCE FACETS_ID_SEQ; - -CREATE TABLE facets ( - id INT PRIMARY KEY NOT NULL, - out_id INT NOT NULL REFERENCES outs(id) ON DELETE CASCADE, - name VARCHAR(256) NOT NULL, - num INT NOT NULL, - state VARCHAR(256) NOT NULL, - description VARCHAR(256), - UNIQUE (out_id, num, name) -); - -CREATE VIEW master_artifacts AS - SELECT a2.id AS id, - a2.gid AS gid, - a2.state AS state, - a2.creation AS creation, - ci2.collection_id AS collection_id - FROM collection_items ci2 - JOIN artifacts a2 - ON ci2.artifact_id = a2.id - JOIN (SELECT ci.collection_id AS c_id, - MIN(a.creation) AS oldest_a - FROM collection_items ci - JOIN artifacts a - ON ci.artifact_id = a.id - GROUP BY ci.collection_id) o - ON o.c_id = ci2.collection_id - WHERE a2.creation = o.oldest_a; - --- DROP VIEW master_artifacts; --- DROP SEQUENCE USERS_ID_SEQ; --- DROP SEQUENCE COLLECTIONS_ID_SEQ; --- DROP SEQUENCE ARTIFACTS_ID_SEQ; --- DROP SEQUENCE COLLECTION_ITEMS_ID_SEQ; --- DROP SEQUENCE ARTIFACT_DATA_ID_SEQ; --- DROP SEQUENCE OUTS_ID_SEQ; --- DROP SEQUENCE FACETS_ID_SEQ; --- DROP TABLE facets; --- DROP TABLE outs; --- DROP TABLE artifact_data; --- DROP TABLE collection_items; --- DROP TABLE collections; --- DROP TABLE artifacts; --- DROP TABLE users; - -COMMIT;