sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gwens...@apache.org
Subject sqoop git commit: SQOOP-2086: Sqoop2: Use named constraints
Date Fri, 06 Feb 2015 21:59:42 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 af3fa2519 -> 003972472


SQOOP-2086: Sqoop2: Use named constraints

(Abraham Elmahrek via Gwen Shapira)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/00397247
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/00397247
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/00397247

Branch: refs/heads/sqoop2
Commit: 003972472a0b70b56ee18d1f802ef3ee83ebd96e
Parents: af3fa25
Author: Gwen Shapira <cshapi@gmail.com>
Authored: Fri Feb 6 13:56:58 2015 -0800
Committer: Gwen Shapira <cshapi@gmail.com>
Committed: Fri Feb 6 13:56:58 2015 -0800

----------------------------------------------------------------------
 .../postgresql/PostgresqlSchemaConstants.java   |  77 ++++++++++++
 .../postgresql/PostgresqlSchemaCreateQuery.java | 126 ++++++++++++++-----
 2 files changed, 173 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/00397247/repository/repository-postgresql/src/main/java/org/apache/sqoop/repository/postgresql/PostgresqlSchemaConstants.java
----------------------------------------------------------------------
diff --git a/repository/repository-postgresql/src/main/java/org/apache/sqoop/repository/postgresql/PostgresqlSchemaConstants.java
b/repository/repository-postgresql/src/main/java/org/apache/sqoop/repository/postgresql/PostgresqlSchemaConstants.java
index e645c7d..50c98b7 100644
--- a/repository/repository-postgresql/src/main/java/org/apache/sqoop/repository/postgresql/PostgresqlSchemaConstants.java
+++ b/repository/repository-postgresql/src/main/java/org/apache/sqoop/repository/postgresql/PostgresqlSchemaConstants.java
@@ -17,6 +17,9 @@
  */
 package org.apache.sqoop.repository.postgresql;
 
+import static org.apache.sqoop.repository.common.CommonRepositorySchemaConstants.CONSTRAINT_PREFIX;
+import static org.apache.sqoop.repository.common.CommonRepositorySchemaConstants.SCHEMA_PREFIX;
+
 public class PostgresqlSchemaConstants {
   public static final String SCHEMA_SQOOP = "SQOOP";
 
@@ -275,6 +278,80 @@ public class PostgresqlSchemaConstants {
 
   public static final String COLUMN_SQRS_VALUE = "SQRS_VALUE";
 
+  // Constraints
+
+  public static final String CONSTRAINT_SQCD_SQC_NAME
+      = CONSTRAINT_PREFIX + "SQCD_SQC";
+
+  public static final String CONSTRAINT_SQCD_SQD_NAME
+      = CONSTRAINT_PREFIX + "SQCD_SQD";
+
+  public static final String CONSTRAINT_SQ_CONFIGURABLE_UNIQUE_NAME
+      = CONSTRAINT_PREFIX + "SQC_NAME_UNIQUE";
+
+  public static final String CONSTRAINT_SQ_CFG_DIR_CONFIG_NAME
+      = CONSTRAINT_PREFIX + "SQ_CFG_DIR_CONFIG";
+
+  public static final String CONSTRAINT_SQ_CFG_DIR_DIRECTION_NAME
+      = CONSTRAINT_PREFIX + "SQ_CFG_DIR_DIRECTION";
+
+  public static final String CONSTRAINT_SQ_CFG_SQC_NAME
+      = CONSTRAINT_PREFIX + "SQ_CFG_SQC";
+
+  public static final String CONSTRAINT_SQ_CONFIG_UNIQUE_NAME_TYPE_CONFIGURABLE
+      = CONSTRAINT_PREFIX + "SQ_CFG_NAME_TYPE_CONFIGURABLE_UNIQUE";
+
+  public static final String CONSTRAINT_SQI_SQ_CFG_NAME
+      = CONSTRAINT_PREFIX + "SQI_SQ_CFG";
+
+  public static final String CONSTRAINT_SQ_INPUT_UNIQUE_NAME_TYPE_CONFIG
+      = CONSTRAINT_PREFIX + "SQI_NAME_TYPE_CONFIG_UNIQUE";
+
+  public static final String CONSTRAINT_SQIR_PARENT_NAME
+      = CONSTRAINT_PREFIX + "SQIR_PARENT_ID";
+
+  public static final String CONSTRAINT_SQIR_CHILD_NAME
+      = CONSTRAINT_PREFIX + "SQIR_CHILD_ID";
+
+  public static final String CONSTRAINT_SQ_LNK_SQC_NAME
+      = CONSTRAINT_PREFIX + "SQ_LNK_SQC";
+
+  public static final String CONSTRAINT_SQ_LNK_NAME_UNIQUE_NAME
+      = CONSTRAINT_PREFIX + "SQ_LNK_NAME_UNIQUE";
+
+  public static final String CONSTRAINT_SQB_SQ_LNK_FROM_NAME
+      = CONSTRAINT_PREFIX + "SQB_SQ_LNK_FROM";
+
+  public static final String CONSTRAINT_SQB_SQ_LNK_TO_NAME
+      = CONSTRAINT_PREFIX + "SQB_SQ_LNK_TO";
+
+  public static final String CONSTRAINT_SQB_NAME_UNIQUE_NAME
+      = CONSTRAINT_PREFIX + "SQB_NAME_UNIQUE";
+
+  public static final String CONSTRAINT_SQ_LNKI_SQ_LNK_NAME
+      = CONSTRAINT_PREFIX + "SQ_LNKI_SQ_LNK";
+
+  public static final String CONSTRAINT_SQ_LNKI_SQI_NAME
+      = CONSTRAINT_PREFIX + "SQ_LNKI_SQI";
+
+  public static final String CONSTRAINT_SQBI_SQB_NAME
+      = CONSTRAINT_PREFIX + "SQBI_SQB";
+
+  public static final String CONSTRAINT_SQBI_SQI_NAME
+      = CONSTRAINT_PREFIX + "SQBI_SQI";
+
+  public static final String CONSTRAINT_SQS_SQB_NAME
+      = CONSTRAINT_PREFIX + "SQS_SQB";
+
+  public static final String CONSTRAINT_SQRS_SQG_NAME
+      = CONSTRAINT_PREFIX + "SQRS_SQG";
+
+  public static final String CONSTRAINT_SQRS_SQR_NAME
+      = CONSTRAINT_PREFIX + "SQRS_SQR";
+
+  public static final String CONSTRAINT_SQRS_SQS_NAME
+      = CONSTRAINT_PREFIX + "SQRS_SQS";
+
   private PostgresqlSchemaConstants() {
     // Disable explicit object creation
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/00397247/repository/repository-postgresql/src/main/java/org/apache/sqoop/repository/postgresql/PostgresqlSchemaCreateQuery.java
----------------------------------------------------------------------
diff --git a/repository/repository-postgresql/src/main/java/org/apache/sqoop/repository/postgresql/PostgresqlSchemaCreateQuery.java
b/repository/repository-postgresql/src/main/java/org/apache/sqoop/repository/postgresql/PostgresqlSchemaCreateQuery.java
index 51d0bd6..c02ab48 100644
--- a/repository/repository-postgresql/src/main/java/org/apache/sqoop/repository/postgresql/PostgresqlSchemaCreateQuery.java
+++ b/repository/repository-postgresql/src/main/java/org/apache/sqoop/repository/postgresql/PostgresqlSchemaCreateQuery.java
@@ -17,9 +17,11 @@
  */
 package org.apache.sqoop.repository.postgresql;
 
+import org.apache.sqoop.repository.common.CommonRepoConstants;
 import org.apache.sqoop.repository.common.CommonRepoUtils;
 import org.apache.sqoop.repository.common.CommonRepositorySchemaConstants;
 
+import static org.apache.sqoop.repository.common.CommonRepositorySchemaConstants.SCHEMA_SQOOP;
 import static org.apache.sqoop.repository.postgresql.PostgresqlSchemaConstants.*;
 
 /**
@@ -268,7 +270,8 @@ public class PostgresqlSchemaCreateQuery {
   public static final String QUERY_CREATE_TABLE_SQ_CONFIGURABLE =
       "CREATE TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIGURABLE_NAME)
+ " ("
           + CommonRepoUtils.escapeColumnName(COLUMN_SQC_ID) + " BIGSERIAL PRIMARY KEY NOT
NULL, "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQC_NAME) + " VARCHAR(64) UNIQUE, "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQC_NAME) + " VARCHAR(64) CONSTRAINT
"
+            + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQ_CONFIGURABLE_UNIQUE_NAME)
+ " UNIQUE, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQC_TYPE) + " VARCHAR(32), "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQC_CLASS) + " VARCHAR(255), "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQC_VERSION) + " VARCHAR(64) "
@@ -277,93 +280,144 @@ public class PostgresqlSchemaCreateQuery {
   public static final String QUERY_CREATE_TABLE_SQ_CONNECTOR_DIRECTIONS =
       "CREATE TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONNECTOR_DIRECTIONS_NAME)
+ " ("
           + CommonRepoUtils.escapeColumnName(COLUMN_SQCD_ID) + " BIGSERIAL PRIMARY KEY NOT
NULL, "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQCD_CONNECTOR) + " BIGINT REFERENCES
" + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIGURABLE_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQC_ID)
+ ")" + ", "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQCD_DIRECTION) + " BIGINT REFERENCES
" + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_DIRECTION_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQD_ID)
+ ")"
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQCD_CONNECTOR) + " BIGINT, "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQCD_DIRECTION) + " BIGINT, "
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQCD_SQC_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQCD_CONNECTOR)
+ ") REFERENCES "
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIGURABLE_NAME) +
"("  + CommonRepoUtils.escapeColumnName(COLUMN_SQC_ID) + "), "
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQCD_SQD_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQCD_DIRECTION)
+ ") REFERENCES "
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_DIRECTION_NAME) + "("
 + CommonRepoUtils.escapeColumnName(COLUMN_SQD_ID) + ")"
           + ")";
 
   public static final String QUERY_CREATE_TABLE_SQ_CONFIG =
       "CREATE TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIG_NAME)
+ " ("
           + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_ID) + " BIGSERIAL PRIMARY KEY
NOT NULL, "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_CONFIGURABLE) + " BIGINT REFERENCES
" + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIGURABLE_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQC_ID)
+ ")" + ", "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_CONFIGURABLE) + " BIGINT, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_NAME) + " VARCHAR(64), "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_TYPE) + " VARCHAR(32), "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_INDEX) + " SMALLINT, "
-          + "UNIQUE (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_NAME) + ", " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_TYPE)
+ ", " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_CONFIGURABLE) + ") "
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQ_CFG_SQC_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_CONFIGURABLE)
+ ") REFERENCES "
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIGURABLE_NAME) +
"("  + CommonRepoUtils.escapeColumnName(COLUMN_SQC_ID) + "),"
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQ_CONFIG_UNIQUE_NAME_TYPE_CONFIGURABLE)
+            + " UNIQUE (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_NAME) + ", " +
CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_TYPE) + ", " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_CONFIGURABLE)
+ ") "
           + ")";
 
   public static final String QUERY_CREATE_TABLE_SQ_CONFIG_DIRECTIONS =
       "CREATE TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIG_DIRECTIONS_NAME)
+ " ("
           + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_DIR_ID) + " BIGSERIAL PRIMARY
KEY NOT NULL, "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_DIR_CONFIG) + " BIGINT REFERENCES
" + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIG_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_ID)
+ ")" + ", "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_DIR_DIRECTION) + " BIGINT REFERENCES
" + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_DIRECTION_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQD_ID)
+ ")"
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_DIR_CONFIG) + " BIGINT, "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_DIR_DIRECTION) + " BIGINT, "
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQ_CFG_DIR_CONFIG_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_DIR_CONFIG)
+ ") REFERENCES "
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIG_NAME) + "("  +
CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_ID) + "), "
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQ_CFG_DIR_DIRECTION_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_DIR_DIRECTION)
+ ") REFERENCES "
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_DIRECTION_NAME) + "("
 + CommonRepoUtils.escapeColumnName(COLUMN_SQD_ID) + ")"
           + ")";
 
   public static final String QUERY_CREATE_TABLE_SQ_INPUT =
       "CREATE TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME) +
" ("
           + CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID) + " BIGSERIAL PRIMARY KEY NOT
NULL, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQI_NAME) + " VARCHAR(64), "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQI_CONFIG) + " BIGINT REFERENCES " +
CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIG_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_ID)
+ ")" + ", "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQI_CONFIG) + " BIGINT, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQI_INDEX) + " SMALLINT, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQI_TYPE) + " VARCHAR(32), "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQI_STRMASK) + " BOOLEAN, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQI_STRLENGTH) + " SMALLINT, "
           + CommonRepoUtils.escapeColumnName(CommonRepositorySchemaConstants.COLUMN_SQI_EDITABLE)
+ " VARCHAR(32), "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQI_ENUMVALS) + " VARCHAR(100), "
-          + " UNIQUE (" + CommonRepoUtils.escapeColumnName(COLUMN_SQI_NAME) + ", " + CommonRepoUtils.escapeColumnName(COLUMN_SQI_TYPE)
+ ", " + CommonRepoUtils.escapeColumnName(COLUMN_SQI_CONFIG) + ") "
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQI_SQ_CFG_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQI_CONFIG) + ")
REFERENCES "
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIG_NAME) + "("  +
CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_ID) + "), "
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQ_INPUT_UNIQUE_NAME_TYPE_CONFIG)
+            + " UNIQUE (" + CommonRepoUtils.escapeColumnName(COLUMN_SQI_NAME) + ", "
+                          + CommonRepoUtils.escapeColumnName(COLUMN_SQI_TYPE) + ", "
+                          + CommonRepoUtils.escapeColumnName(COLUMN_SQI_CONFIG) + ") "
           + ")";
 
   public static final String QUERY_CREATE_TABLE_SQ_INPUT_RELATION =
       "CREATE TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, CommonRepositorySchemaConstants.TABLE_SQ_INPUT_RELATION_NAME)
+ " ("
           + CommonRepoUtils.escapeColumnName(CommonRepositorySchemaConstants.COLUMN_SQIR_ID)
+ " BIGSERIAL PRIMARY KEY NOT NULL, "
-          + CommonRepoUtils.escapeColumnName(CommonRepositorySchemaConstants.COLUMN_SQIR_PARENT)
+ " BIGINT REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME)
+ "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID) + ")" + ", "
-          + CommonRepoUtils.escapeColumnName(CommonRepositorySchemaConstants.COLUMN_SQIR_CHILD)
+ " BIGINT REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME)
+ "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID) + ")"
+          + CommonRepoUtils.escapeColumnName(CommonRepositorySchemaConstants.COLUMN_SQIR_PARENT)
+ " BIGINT, "
+          + CommonRepoUtils.escapeColumnName(CommonRepositorySchemaConstants.COLUMN_SQIR_CHILD)
+ " BIGINT, "
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQIR_PARENT_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(CommonRepositorySchemaConstants.COLUMN_SQIR_PARENT)
+ ") REFERENCES "
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME) + "("  +
CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID) + "), "
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQIR_CHILD_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(CommonRepositorySchemaConstants.COLUMN_SQIR_CHILD)
+ ") REFERENCES "
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME) + "("  +
CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID) + ")"
           + ")";
 
   public static final String QUERY_CREATE_TABLE_SQ_LINK =
       "CREATE TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) +
" ("
           + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID) + " BIGSERIAL PRIMARY KEY
NOT NULL, "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_CONFIGURABLE) + " BIGINT REFERENCES
" + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIGURABLE_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQC_ID)
+ ")" + ", "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_NAME)  + " VARCHAR(32) UNIQUE,
"
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_CONFIGURABLE) + " BIGINT, "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_NAME)  + " VARCHAR(32) CONSTRAINT
"
+            + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQ_LNK_NAME_UNIQUE_NAME) +
 " UNIQUE, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_CREATION_DATE) + " TIMESTAMP,
"
           + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_CREATION_USER) + " VARCHAR(32)
DEFAULT NULL, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_UPDATE_DATE) + " TIMESTAMP, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_UPDATE_USER) + " VARCHAR(32) DEFAULT
NULL, "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ENABLED) + " BOOLEAN DEFAULT TRUE"
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ENABLED) + " BOOLEAN DEFAULT TRUE,
"
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQ_LNK_SQC_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_CONFIGURABLE)
+ ") REFERENCES "
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIGURABLE_NAME) +
"("  + CommonRepoUtils.escapeColumnName(COLUMN_SQC_ID) + ")"
           + ")";
 
   public static final String QUERY_CREATE_TABLE_SQ_JOB =
       "CREATE TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + "
("
           + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID) + " BIGSERIAL PRIMARY KEY NOT
NULL, "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQB_FROM_LINK) + " BIGINT REFERENCES
" + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID)
+ ")" + ", "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQB_TO_LINK) + " BIGINT REFERENCES "
+ CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID)
+ ")" + ", "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQB_NAME) + " VARCHAR(64) UNIQUE, "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQB_FROM_LINK) + " BIGINT, "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQB_TO_LINK) + " BIGINT, "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQB_NAME) + " VARCHAR(64) CONSTRAINT
"
+            + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQB_NAME_UNIQUE_NAME) +  "
UNIQUE, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQB_CREATION_DATE) + " TIMESTAMP, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQB_CREATION_USER) + " VARCHAR(32) DEFAULT
NULL, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQB_UPDATE_DATE) + " TIMESTAMP, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQB_UPDATE_USER) + " VARCHAR(32) DEFAULT
NULL, "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ENABLED) + " BOOLEAN DEFAULT TRUE"
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ENABLED) + " BOOLEAN DEFAULT TRUE,
"
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQB_SQ_LNK_FROM_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQB_FROM_LINK) +
") REFERENCES "
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID)
+ "), "
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQB_SQ_LNK_TO_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQB_TO_LINK) + ")
REFERENCES "
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID)
+ ")"
           + ")";
 
   public static final String QUERY_CREATE_TABLE_SQ_LINK_INPUT =
       "CREATE TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_INPUT_NAME)
+ " ("
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_LINK) + " BIGINT REFERENCES "
+ CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID)
+ ")" + ", "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_INPUT) + " BIGINT REFERENCES
" + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID)
+ ")" + ", "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_LINK) + " BIGINT, "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_INPUT) + " BIGINT, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_VALUE) + " VARCHAR, "
-          + "PRIMARY KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_LINK) + ",
" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_INPUT) + ")"
+          + "PRIMARY KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_LINK) + ",
" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_INPUT) + "), "
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQ_LNKI_SQ_LNK_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_LINK) +
") REFERENCES "
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID)
+ "), "
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQ_LNKI_SQI_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_INPUT) +
") REFERENCES "
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME) + "("  +
CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID) + ")"
           + ")";
 
   public static final String QUERY_CREATE_TABLE_SQ_JOB_INPUT =
       "CREATE TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_INPUT_NAME)
+ " ("
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_JOB) + " BIGINT REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP,
TABLE_SQ_JOB_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID) + ")" + ", "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_INPUT) + " BIGINT REFERENCES " +
CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID)
+ ")" + ", "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_JOB) + " BIGINT, "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_INPUT) + " BIGINT, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_VALUE) + " VARCHAR(1000), "
-          + "PRIMARY KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_JOB) + ", " +
CommonRepoUtils.escapeColumnName(COLUMN_SQBI_INPUT) + ")"
+          + "PRIMARY KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_JOB) + ", " +
CommonRepoUtils.escapeColumnName(COLUMN_SQBI_INPUT) + "), "
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQBI_SQB_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_JOB) + ") REFERENCES
"
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID)
+ "), "
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQBI_SQI_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_INPUT) + ")
REFERENCES "
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME) + "("  +
CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID) + ")"
           + ")";
 
   public static final String QUERY_CREATE_TABLE_SQ_SUBMISSION =
       "CREATE TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_SUBMISSION_NAME)
+ " ("
           + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ID) + " BIGSERIAL PRIMARY KEY NOT
NULL, "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQS_JOB) + " BIGINT REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP,
TABLE_SQ_JOB_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID) + ") ON DELETE
CASCADE, "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQS_JOB) + " BIGINT, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQS_STATUS) + " VARCHAR(20), "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQS_CREATION_DATE) + " TIMESTAMP, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQS_CREATION_USER) + " VARCHAR(32) DEFAULT
NULL, "
@@ -372,7 +426,10 @@ public class PostgresqlSchemaCreateQuery {
           + CommonRepoUtils.escapeColumnName(COLUMN_SQS_EXTERNAL_ID) + " VARCHAR(50), "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQS_EXTERNAL_LINK) + " VARCHAR(150),
"
           + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ERROR_SUMMARY) + " VARCHAR(150),
"
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ERROR_DETAILS) + " VARCHAR(750)"
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ERROR_DETAILS) + " VARCHAR(750),
"
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQS_SQB_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQS_JOB) + ") REFERENCES
"
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID)
+ ") ON DELETE CASCADE"
           + ")";
 
   public static final String QUERY_CREATE_TABLE_SQ_COUNTER_GROUP =
@@ -389,11 +446,20 @@ public class PostgresqlSchemaCreateQuery {
 
   public static final String QUERY_CREATE_TABLE_SQ_COUNTER_SUBMISSION =
       "CREATE TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_COUNTER_SUBMISSION_NAME)
+ " ("
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQRS_GROUP) + " BIGINT REFERENCES " +
CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_COUNTER_GROUP_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQG_ID)
+ ")" + ", "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQRS_COUNTER) + " BIGINT REFERENCES "
+ CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_COUNTER_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQR_ID)
+ ")" + ", "
-          + CommonRepoUtils.escapeColumnName(COLUMN_SQRS_SUBMISSION) + " BIGINT REFERENCES
" + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_SUBMISSION_NAME) + "("  + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ID)
+ ") ON DELETE CASCADE" + ", "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQRS_GROUP) + " BIGINT, "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQRS_COUNTER) + " BIGINT, "
+          + CommonRepoUtils.escapeColumnName(COLUMN_SQRS_SUBMISSION) + " BIGINT, "
           + CommonRepoUtils.escapeColumnName(COLUMN_SQRS_VALUE) + " BIGINT, "
-          + "PRIMARY KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQRS_GROUP) + ", "
+ CommonRepoUtils.escapeColumnName(COLUMN_SQRS_COUNTER) + ", " + CommonRepoUtils.escapeColumnName(COLUMN_SQRS_SUBMISSION)
+ ")"
+          + "PRIMARY KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQRS_GROUP) + ", "
+ CommonRepoUtils.escapeColumnName(COLUMN_SQRS_COUNTER) + ", " + CommonRepoUtils.escapeColumnName(COLUMN_SQRS_SUBMISSION)
+ "), "
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQRS_SQG_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQRS_GROUP) + ")
REFERENCES "
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_COUNTER_GROUP_NAME) +
"("  + CommonRepoUtils.escapeColumnName(COLUMN_SQG_ID) + "), "
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQRS_SQR_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQRS_COUNTER) +
") REFERENCES "
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_COUNTER_NAME) + "(" 
+ CommonRepoUtils.escapeColumnName(COLUMN_SQR_ID) + "), "
+          + "CONSTRAINT " + CommonRepoUtils.escapeConstraintName(CONSTRAINT_SQRS_SQS_NAME)
+            + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQRS_SUBMISSION)
+ ") REFERENCES "
+              + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_SUBMISSION_NAME) + "("
 + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ID) + ") ON DELETE CASCADE"
           + ")";
 
   private PostgresqlSchemaCreateQuery() {


Mime
View raw message