Salome HOME
Work on Profile
[modules/gde.git] / projects / GDE_App / src / GDE_DB_Init.sql
index 10ecb1638f958ea42b2077b2ebe84d9998ae025e..870b5f2febb595da45374c1f30fe115f59affa8d 100644 (file)
@@ -1,6 +1,6 @@
 /* Unique Ids sequence generator */
 
-drop sequence SEQ_GEN_SEQUENCE;
+drop sequence if exists SEQ_GEN_SEQUENCE;
 create sequence SEQ_GEN_SEQUENCE START WITH 1000 INCREMENT BY 50;
 
 
@@ -26,6 +26,8 @@ CREATE TABLE USERGROUP (
 );
 create index usergroup_groupId_idx ON USERGROUP(groupId);
 
+
+
 DROP TABLE IF EXISTS GROUPPERMISSIONS CASCADE;
 CREATE TABLE GROUPPERMISSIONS (
     id bigint NOT NULL PRIMARY KEY,
@@ -47,17 +49,26 @@ CREATE TABLE attribute (
     name varchar(255),
     type varchar(255),
     value varchar(255),
-    attribute_group_id bigint REFERENCES attribute_group (id),
+    attribute_group_id bigint not null REFERENCES attribute_group (id),
     mandatory boolean
 );
 
-DROP TABLE IF EXISTS attribute_group_attribute CASCADE;
-CREATE TABLE attribute_group_attribute (
-    attributegroup_id bigint REFERENCES attribute_group (id) on delete cascade,
-    attribute_id bigint REFERENCES attribute(id) on delete cascade
+/* PROFILE */
+
+DROP TABLE IF EXISTS profile CASCADE;
+CREATE TABLE profile (
+    id bigint NOT NULL PRIMARY KEY,
+    name varchar(255)
+);
+
+DROP TABLE IF EXISTS profile_attribute CASCADE;
+CREATE TABLE profile_attribute (
+    id bigint NOT NULL PRIMARY KEY,
+    name varchar(255),
+    type varchar(255),
+    mandatory boolean,
+    profile_id bigint not null REFERENCES profile (id)
 );
-CREATE INDEX attribute_group_attribute_idx1 on attribute_group_attribute(attributegroup_id);
-CREATE INDEX attribute_group_attribute_idx2 on attribute_group_attribute(attribute_id);
 
 /* DATA */
 
@@ -103,20 +114,6 @@ CREATE TABLE study (
 );
 /* PROFILES */
 
-DROP TABLE IF EXISTS profile CASCADE;
-CREATE TABLE profile (
-    id bigint NOT NULL PRIMARY KEY,
-    name varchar(255)
-);
-
-DROP TABLE IF EXISTS profile_attribute CASCADE;
-CREATE TABLE profile_attribute (
-    id bigint NOT NULL PRIMARY KEY,
-    name varchar(255),
-    type varchar(255),
-    mandatory boolean,
-    profile_id bigint REFERENCES profile (id)
-);
 
 -- The 1000 first ids are reserved for initial data
 INSERT INTO users (id,username,userpassword) VALUES (1,'admin','edf123');