airavata-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From machris...@apache.org
Subject [airavata] branch airavata-2938-change-db-initialization-in-registry-server-to-use-registry-refactoring-code updated: AIRAVATA-2938 Self-referencing FK added in ALTER TABLE statement
Date Thu, 31 Jan 2019 16:55:33 GMT
This is an automated email from the ASF dual-hosted git repository.

machristie pushed a commit to branch airavata-2938-change-db-initialization-in-registry-server-to-use-registry-refactoring-code
in repository https://gitbox.apache.org/repos/asf/airavata.git


The following commit(s) were added to refs/heads/airavata-2938-change-db-initialization-in-registry-server-to-use-registry-refactoring-code
by this push:
     new 90d0304  AIRAVATA-2938 Self-referencing FK added in ALTER TABLE statement
90d0304 is described below

commit 90d03041d804be838c8c652f5fd5eb4124adbfab
Author: Marcus Christie <machristie@apache.org>
AuthorDate: Thu Jan 31 11:55:23 2019 -0500

    AIRAVATA-2938 Self-referencing FK added in ALTER TABLE statement
    
    Appears that in Derby you can't have a self-reference FK in a
    CREATE TABLE statement
---
 .../src/main/resources/replicacatalog-derby.sql                   | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/modules/registry-refactoring/src/main/resources/replicacatalog-derby.sql b/modules/registry-refactoring/src/main/resources/replicacatalog-derby.sql
index ffd8055..3d9ed3b 100644
--- a/modules/registry-refactoring/src/main/resources/replicacatalog-derby.sql
+++ b/modules/registry-refactoring/src/main/resources/replicacatalog-derby.sql
@@ -32,10 +32,14 @@ CREATE TABLE DATA_PRODUCT
         CREATION_TIME TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
         LAST_MODIFIED_TIME TIMESTAMP DEFAULT '0000-00-00 00:00:00',
         PRODUCT_TYPE VARCHAR(10),
-        PRIMARY KEY (PRODUCT_URI),
-        FOREIGN KEY (PARENT_PRODUCT_URI) REFERENCES DATA_PRODUCT (PRODUCT_URI) ON DELETE
CASCADE
+        PRIMARY KEY (PRODUCT_URI)
+        -- in Derby can't create self-reference FOREIGN KEY in CREATE TABLE
+        -- statement so this gets added via the following ALTER TABLE statement
+        -- FOREIGN KEY (PARENT_PRODUCT_URI) REFERENCES DATA_PRODUCT (PRODUCT_URI) ON DELETE
CASCADE
 );
 
+ALTER TABLE DATA_PRODUCT ADD FOREIGN KEY (PARENT_PRODUCT_URI) REFERENCES DATA_PRODUCT (PRODUCT_URI)
ON DELETE CASCADE;
+
 CREATE TABLE DATA_REPLICA_LOCATION
 (
         REPLICA_ID VARCHAR (255),


Mime
View raw message