]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-4052: Initial ID service 'create table' script for PostgreSQL.
authorAron Roberts <aron@socrates.berkeley.edu>
Sat, 28 May 2011 23:15:21 +0000 (23:15 +0000)
committerAron Roberts <aron@socrates.berkeley.edu>
Sat, 28 May 2011 23:15:21 +0000 (23:15 +0000)
services/id/service/src/main/resources/db/mysql/create_id_generators_table.sql
services/id/service/src/main/resources/db/postgresql/create_id_generators_table.sql [new file with mode: 0644]

index fd443247a01519a6bba2bbc862a80441aaca57cc..5657fbd700f4b82e0d96fab37deeb02b2ebbb504 100644 (file)
  * $LastChangedDate$
  */
 
-/*
- * Note: due to the use of the FLUSH PRIVILEGES command, below,
- * this script must be executed by a database user (such as
- * the root user) who has RELOAD privileges.
-*/
-
 CREATE DATABASE IF NOT EXISTS `cspace`;
 USE `cspace`;
 
diff --git a/services/id/service/src/main/resources/db/postgresql/create_id_generators_table.sql b/services/id/service/src/main/resources/db/postgresql/create_id_generators_table.sql
new file mode 100644 (file)
index 0000000..47adeba
--- /dev/null
@@ -0,0 +1,58 @@
+/*     
+ * This document is a part of the source code and related artifacts
+ * for CollectionSpace, an open source collections management system
+ * for museums and related institutions:
+ *
+ * http://www.collectionspace.org
+ * http://wiki.collectionspace.org
+ *
+ * Copyright © 2009 Regents of the University of California
+ *
+ * Licensed under the Educational Community License (ECL), Version 2.0.
+ * You may not use this file except in compliance with this License.
+ *
+ * You may obtain a copy of the ECL 2.0 License at
+ * https://source.collectionspace.org/collection-space/LICENSE.txt
+ */
+
+/*
+ * create_id_generators_table.sql
+ *
+ * Creates the "id_generators" table, used by the ID Service,
+ * and sets the access permissions of that table.
+ *
+ * $LastChangedRevision$
+ * $LastChangedDate$
+ */
+
+-- Will return non-fatal failure result code and error message
+-- if this database already exists.
+CREATE DATABASE cspace WITH ENCODING = 'UTF8';
+
+-- Explicitly use this database before creating a table within it
+-- (only works with scripts executed by the 'psql' client).
+\c cspace;
+
+DROP TABLE IF EXISTS id_generators;
+CREATE TABLE id_generators
+(
+  csid character varying(80) NOT NULL,
+  displayname character varying(80),
+  description character varying(500),
+  priority integer NOT NULL DEFAULT 9,
+  id_generator_state character varying(8000) NOT NULL,
+  last_generated_id character varying(255),
+  modified timestamp without time zone NOT NULL DEFAULT now(),
+  CONSTRAINT id_generators_pkey PRIMARY KEY (csid)
+) WITH (
+  OIDS=FALSE -- See http://www.postgresql.org/docs/8.4/static/sql-createtable.html
+);
+
+-- CREATE UNIQUE INDEX csid_idx ON id_generators USING btree (csid);
+
+-- Update the timestamp in the 'modified' field when the record is updated.
+CREATE OR REPLACE RULE update_idgenerators_timestamp AS
+  ON UPDATE TO id_generators
+  DO INSERT INTO id_generators (modified)
+  VALUES (now());
+