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-2087: Sqoop2: Named constraints should be quoted
Date Fri, 06 Feb 2015 20:25:20 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 98544cc97 -> af3fa2519


SQOOP-2087: Sqoop2: Named constraints should be quoted

(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/af3fa251
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/af3fa251
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/af3fa251

Branch: refs/heads/sqoop2
Commit: af3fa2519bd80c38d460b897f9fffbdbd827d5d4
Parents: 98544cc
Author: Gwen Shapira <cshapi@gmail.com>
Authored: Fri Feb 6 12:23:25 2015 -0800
Committer: Gwen Shapira <cshapi@gmail.com>
Committed: Fri Feb 6 12:23:25 2015 -0800

----------------------------------------------------------------------
 .../repository/common/CommonRepoUtils.java      | 12 ++++
 .../derby/DerbySchemaCreateQuery.java           | 36 ++++++------
 .../derby/DerbySchemaUpgradeQuery.java          | 58 ++++++++++----------
 3 files changed, 59 insertions(+), 47 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/af3fa251/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepoUtils.java
----------------------------------------------------------------------
diff --git a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepoUtils.java
b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepoUtils.java
index 5121962..95e3bb8 100644
--- a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepoUtils.java
+++ b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepoUtils.java
@@ -32,6 +32,10 @@ public class CommonRepoUtils {
     return TABLE_NAME_QUOTE_CHAR + schemaName + TABLE_NAME_QUOTE_CHAR;
   }
 
+  public static final String escapeConstraintName(String constraintName) {
+    return TABLE_NAME_QUOTE_CHAR + constraintName + TABLE_NAME_QUOTE_CHAR;
+  }
+
   public static final String getTableName(String schemaName, String tableName) {
     if (schemaName != null) {
       return escapeSchemaName(schemaName) + "." + escapeTableName(tableName);
@@ -47,4 +51,12 @@ public class CommonRepoUtils {
       return escapeColumnName(columnName);
     }
   }
+
+  public static final String getConstraintName(String schemaName, String constraintName)
{
+    if (schemaName != null) {
+      return escapeSchemaName(schemaName) + "." + escapeConstraintName(constraintName);
+    } else {
+      return escapeConstraintName(constraintName);
+    }
+  }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/af3fa251/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaCreateQuery.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaCreateQuery.java
b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaCreateQuery.java
index d501a5d..acc802d 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaCreateQuery.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaCreateQuery.java
@@ -327,10 +327,10 @@ public final class DerbySchemaCreateQuery {
       + CommonRepoUtils.escapeColumnName(COLUMN_SQCD_ID) + " BIGINT GENERATED ALWAYS AS IDENTITY
(START WITH 1, INCREMENT BY 1) PRIMARY KEY, "
       + CommonRepoUtils.escapeColumnName(COLUMN_SQCD_CONNECTOR) + " BIGINT, "
       + CommonRepoUtils.escapeColumnName(COLUMN_SQCD_DIRECTION) + " BIGINT, "
-      + "CONSTRAINT " + CONSTRAINT_SQCD_SQC + " "
+      + "CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQCD_SQC)
+ " "
         + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQCD_CONNECTOR) + ")
"
           + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONNECTOR_NAME)
+ " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQC_ID) + "), "
-      + "CONSTRAINT " + CONSTRAINT_SQCD_SQD + " "
+      + "CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQCD_SQD)
+ " "
         + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQCD_DIRECTION) + ")
"
           + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_DIRECTION_NAME)
+ " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQD_ID) + ")"
       + ")";
@@ -344,7 +344,7 @@ public final class DerbySchemaCreateQuery {
       + CommonRepoUtils.escapeColumnName(COLUMN_SQF_NAME) + " VARCHAR(64), "
       + CommonRepoUtils.escapeColumnName(COLUMN_SQF_TYPE) + " VARCHAR(32), "
       + CommonRepoUtils.escapeColumnName(COLUMN_SQF_INDEX) + " SMALLINT, "
-      + "CONSTRAINT " + CONSTRAINT_SQF_SQC + " "
+      + "CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQF_SQC)
+ " "
         + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQF_CONNECTOR) + ") "
           + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONNECTOR_NAME)
+ " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQC_ID) + ")"
       + ")";
@@ -357,10 +357,10 @@ public final class DerbySchemaCreateQuery {
      + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_DIR_ID) + " BIGINT GENERATED ALWAYS
AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY, "
      + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_DIR_CONFIG) + " BIGINT, "
      + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_DIR_DIRECTION) + " BIGINT, "
-     + "CONSTRAINT " + CONSTRAINT_SQ_CFG_DIR_CONFIG + " "
+     + "CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQ_CFG_DIR_CONFIG)
+ " "
        + "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 " + CONSTRAINT_SQ_CFG_DIR_DIRECTION + " "
+     + "CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQ_CFG_DIR_DIRECTION)
+ " "
        + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_DIR_DIRECTION)
+ ") "
          + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_DIRECTION_NAME)
+ " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQD_ID) + ")"
      + ")";
@@ -377,7 +377,7 @@ public final class DerbySchemaCreateQuery {
       + CommonRepoUtils.escapeColumnName(COLUMN_SQI_STRMASK) + " BOOLEAN, "
       + CommonRepoUtils.escapeColumnName(COLUMN_SQI_STRLENGTH) + " SMALLINT, "
       + CommonRepoUtils.escapeColumnName(COLUMN_SQI_ENUMVALS) + " VARCHAR(100),"
-      + "CONSTRAINT " + CONSTRAINT_SQI_SQF + " "
+      + "CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQI_SQF)
+ " "
         + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQI_FORM) + ") "
           + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_FORM_NAME)
+ " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQF_ID) + ")"
       + ")";
@@ -388,10 +388,10 @@ public final class DerbySchemaCreateQuery {
         + CommonRepoUtils.escapeColumnName(COLUMN_SQIR_ID) + " BIGINT GENERATED ALWAYS AS
IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY, "
         + CommonRepoUtils.escapeColumnName(COLUMN_SQIR_PARENT) + " BIGINT, "
         + CommonRepoUtils.escapeColumnName(COLUMN_SQIR_CHILD) + " BIGINT, "
-        + "CONSTRAINT " + CONSTRAINT_SQIR_PARENT + " "
+        + "CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQIR_PARENT)
+ " "
           + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQIR_PARENT) + ") "
             + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME)
+ " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID) + "),"
-        + "CONSTRAINT " + CONSTRAINT_SQIR_CHILD + " "
+        + "CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQIR_CHILD)
+ " "
           + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQIR_CHILD) + ") "
             + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME)
+ " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID) + ")"
         + ")";
@@ -404,7 +404,7 @@ public final class DerbySchemaCreateQuery {
       + CommonRepoUtils.escapeColumnName(COLUMN_SQN_NAME)  + " VARCHAR(32),"
       + CommonRepoUtils.escapeColumnName(COLUMN_SQN_CREATION_DATE) + " TIMESTAMP,"
       + CommonRepoUtils.escapeColumnName(COLUMN_SQN_UPDATE_DATE) + " TIMESTAMP,"
-      + "CONSTRAINT " + CONSTRAINT_SQN_SQC + " "
+      + "CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQN_SQC)
+ " "
         + "FOREIGN KEY(" + CommonRepoUtils.escapeColumnName(COLUMN_SQN_CONNECTOR) + ") "
           + " REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONNECTOR_NAME)
+ " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQC_ID) + ")"
       + ")";
@@ -417,7 +417,7 @@ public final class DerbySchemaCreateQuery {
      + CommonRepoUtils.escapeColumnName(COLUMN_SQB_TYPE) + " VARCHAR(64),"
      + CommonRepoUtils.escapeColumnName(COLUMN_SQB_CREATION_DATE) + " TIMESTAMP,"
      + CommonRepoUtils.escapeColumnName(COLUMN_SQB_UPDATE_DATE) + " TIMESTAMP,"
-     + "CONSTRAINT " + CONSTRAINT_SQB_SQN + " "
+     + "CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQB_SQN)
+ " "
        + "FOREIGN KEY(" + CommonRepoUtils.escapeColumnName(COLUMN_SQB_CONNECTION) + ") "
          + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONNECTION_NAME)
+ " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQN_ID) + ")"
      + ")";
@@ -430,10 +430,10 @@ public final class DerbySchemaCreateQuery {
       + CommonRepoUtils.escapeColumnName(COLUMN_SQNI_INPUT) + " BIGINT, "
       + CommonRepoUtils.escapeColumnName(COLUMN_SQNI_VALUE) + " LONG VARCHAR,"
       + "PRIMARY KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQNI_CONNECTION) + ", "
+ CommonRepoUtils.escapeColumnName(COLUMN_SQNI_INPUT) + "), "
-      + "CONSTRAINT " + CONSTRAINT_SQNI_SQN + " "
+      + "CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQNI_SQN)
+ " "
         + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQNI_CONNECTION) + ")
"
           + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONNECTION_NAME)
+ " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQN_ID) + "),"
-      + "CONSTRAINT " + CONSTRAINT_SQNI_SQI + " "
+      + "CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQNI_SQI)
+ " "
         + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQNI_INPUT) + ") "
           + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME)
+ " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID) + ")"
       + ")";
@@ -445,10 +445,10 @@ public final class DerbySchemaCreateQuery {
      + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_INPUT) + " BIGINT, "
      + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_VALUE) + " LONG VARCHAR,"
      + " PRIMARY KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_JOB) + ", " + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_INPUT)
+ "), "
-     + " CONSTRAINT " + CONSTRAINT_SQBI_SQB + " "
+     + " CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQBI_SQB)
+ " "
        + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_JOB) + ") "
        +  "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) +
" (" + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID) + "), "
-     + " CONSTRAINT " + CONSTRAINT_SQBI_SQI + " "
+     + " CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQBI_SQI)
+ " "
        + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_INPUT) + ") "
          + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME)
+ " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID) + ")"
      + ")";
@@ -466,7 +466,7 @@ public final class DerbySchemaCreateQuery {
    + CommonRepoUtils.escapeColumnName(COLUMN_SQS_EXCEPTION) + " VARCHAR(150), "
    + CommonRepoUtils.escapeColumnName(COLUMN_SQS_EXCEPTION_TRACE) + " VARCHAR(750), "
    + "PRIMARY KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ID) + "), "
-   + "CONSTRAINT " + CONSTRAINT_SQS_SQB + " "
+   + "CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQS_SQB)
+ " "
      + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQS_JOB) + ") "
        + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) +
"("  + CommonRepoUtils.escapeColumnName(COLUMN_SQB_ID) + ") ON DELETE CASCADE"
    +  ")";
@@ -497,13 +497,13 @@ public final class DerbySchemaCreateQuery {
    + 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) + "), "
-   + "CONSTRAINT " + CONSTRAINT_SQRS_SQG + " "
+   + "CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQRS_SQG)
+ " "
      + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQRS_GROUP) + ") "
        + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_COUNTER_GROUP_NAME)
+ "(" + CommonRepoUtils.escapeColumnName(COLUMN_SQG_ID) + "), "
-   + "CONSTRAINT " + CONSTRAINT_SQRS_SQR + " "
+   + "CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQRS_SQR)
+ " "
      + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQRS_COUNTER) + ") "
        + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_COUNTER_NAME)
+ "(" + CommonRepoUtils.escapeColumnName(COLUMN_SQR_ID) + "), "
-   + "CONSTRAINT " + CONSTRAINT_SQRS_SQS + " "
+   + "CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQRS_SQS)
+ " "
      + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQRS_SUBMISSION) + ") "
        + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_SUBMISSION_NAME)
+ "(" + CommonRepoUtils.escapeColumnName(COLUMN_SQS_ID) + ") ON DELETE CASCADE "
    + ")";

http://git-wip-us.apache.org/repos/asf/sqoop/blob/af3fa251/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaUpgradeQuery.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaUpgradeQuery.java
b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaUpgradeQuery.java
index 606fc68..ddc438d 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaUpgradeQuery.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaUpgradeQuery.java
@@ -105,15 +105,15 @@ public final class DerbySchemaUpgradeQuery {
         + " BIGINT";
 
   public static final String QUERY_UPGRADE_TABLE_SQ_JOB_REMOVE_CONSTRAINT_SQB_SQN =
-      "ALTER TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + "
DROP CONSTRAINT " + CONSTRAINT_SQB_SQN;
+      "ALTER TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + "
DROP CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQB_SQN);
 
   public static final String QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQN_FROM =
-      "ALTER TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + "
ADD CONSTRAINT " + CONSTRAINT_SQB_SQN_FROM
+      "ALTER TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + "
ADD CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQB_SQN_FROM)
           + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQB_FROM_CONNECTION)
+ ") REFERENCES "
           + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONNECTION_NAME) + " (" +
CommonRepoUtils.escapeColumnName(COLUMN_SQN_ID) + ")";
 
   public static final String QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQN_TO =
-      "ALTER TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + "
ADD CONSTRAINT " + CONSTRAINT_SQB_SQN_TO
+      "ALTER TABLE " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + "
ADD CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQB_SQN_TO)
         + " FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQB_TO_CONNECTION) +
") REFERENCES "
         + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONNECTION_NAME) + " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQN_ID)
+ ")";
 
@@ -271,15 +271,15 @@ public final class DerbySchemaUpgradeQuery {
   // rename upgrades as part of the refactoring SQOOP-1498
   // table rename for CONNECTION-> LINK
   public static final String QUERY_UPGRADE_DROP_TABLE_SQ_CONNECTION_CONSTRAINT_1 = "ALTER
TABLE "
-      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONNECTION_INPUT_NAME) + " DROP
CONSTRAINT " + CONSTRAINT_SQNI_SQI;
+      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONNECTION_INPUT_NAME) + " DROP
CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQNI_SQI);
   public static final String QUERY_UPGRADE_DROP_TABLE_SQ_CONNECTION_CONSTRAINT_2 = "ALTER
TABLE "
-      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONNECTION_INPUT_NAME) + " DROP
CONSTRAINT " + CONSTRAINT_SQNI_SQN;
+      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONNECTION_INPUT_NAME) + " DROP
CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQNI_SQN);
 
   public static final String QUERY_UPGRADE_DROP_TABLE_SQ_CONNECTION_CONSTRAINT_3 = "ALTER
TABLE "
-      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + " DROP CONSTRAINT
" + CONSTRAINT_SQB_SQN_FROM;
+      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + " DROP CONSTRAINT
" + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQB_SQN_FROM);
 
   public static final String QUERY_UPGRADE_DROP_TABLE_SQ_CONNECTION_CONSTRAINT_4 = "ALTER
TABLE "
-      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + " DROP CONSTRAINT
" + CONSTRAINT_SQB_SQN_TO;
+      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + " DROP CONSTRAINT
" + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQB_SQN_TO);
 
   public static final String QUERY_UPGRADE_RENAME_TABLE_SQ_CONNECTION_TO_SQ_LINK = "RENAME
TABLE "
       + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONNECTION_NAME) + " TO SQ_LINK";
@@ -304,10 +304,10 @@ public final class DerbySchemaUpgradeQuery {
 
   // rename the constraint CONSTRAINT_SQF_SQC to CONSTRAINT_SQ_CFG_SQC
   public static final String QUERY_UPGRADE_DROP_TABLE_SQ_CONNECTION_CONNECTOR_CONSTRAINT
= "ALTER TABLE "
-      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + " DROP CONSTRAINT
" + CONSTRAINT_SQN_SQC;
+      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + " DROP CONSTRAINT
" + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQN_SQC);
 
   public static final String QUERY_UPGRADE_ADD_TABLE_SQ_LINK_CONNECTOR_CONSTRAINT = "ALTER
TABLE "
-      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + " ADD CONSTRAINT
" + CONSTRAINT_SQ_LNK_SQC + " " + "FOREIGN KEY ("
+      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + " ADD CONSTRAINT
" + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQ_LNK_SQC) + " " + "FOREIGN
KEY ("
       + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_CONNECTOR) + ") " + "REFERENCES "
+ CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONNECTOR_NAME) + " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQC_ID)
       + ")";
 
@@ -323,13 +323,13 @@ public final class DerbySchemaUpgradeQuery {
       + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_INPUT_NAME) + "." + CommonRepoUtils.escapeColumnName(COLUMN_SQNI_VALUE)
+ " TO " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_VALUE);
   // add the dropped LINK table constraint to the LINK_INPUT
   public static final String QUERY_UPGRADE_ADD_TABLE_SQ_LINK_INPUT_CONSTRAINT = "ALTER TABLE
"
-      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_INPUT_NAME) + " ADD CONSTRAINT
" + CONSTRAINT_SQ_LNKI_SQ_LNK + " "
+      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_INPUT_NAME) + " ADD CONSTRAINT
" + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQ_LNKI_SQ_LNK) + " "
       + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_LINK) + ") " +
"REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + " ("
       + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID) + ")";
 
   // table rename for FORM-> CONFIG
   public static final String QUERY_UPGRADE_DROP_TABLE_SQ_FORM_CONSTRAINT = "ALTER TABLE "
-      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME) + " DROP CONSTRAINT
" + CONSTRAINT_SQI_SQF;
+      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME) + " DROP CONSTRAINT
" + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQI_SQF);
 
   public static final String QUERY_UPGRADE_RENAME_TABLE_SQ_FORM_TO_SQ_CONFIG = "RENAME TABLE
"
       + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_FORM_NAME) + " TO SQ_CONFIG";
@@ -350,12 +350,12 @@ public final class DerbySchemaUpgradeQuery {
 
   // rename the constraint CONSTRAINT_SQF_SQC to CONSTRAINT_SQ_CFG_SQC
   public static final String QUERY_UPGRADE_DROP_TABLE_SQ_FORM_CONNECTOR_CONSTRAINT = "ALTER
TABLE "
-      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIG_NAME) + " DROP CONSTRAINT
" + CONSTRAINT_SQF_SQC;
+      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIG_NAME) + " DROP CONSTRAINT
" + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQF_SQC);
 
   public static final String QUERY_UPGRADE_ADD_TABLE_SQ_CONFIG_CONNECTOR_CONSTRAINT = "ALTER
TABLE "
       + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIG_NAME)
       + " ADD CONSTRAINT "
-      + CONSTRAINT_SQ_CFG_SQC
+      + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQ_CFG_SQC)
       + " "
       + "FOREIGN KEY ("
       + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_CONNECTOR)
@@ -371,8 +371,8 @@ public final class DerbySchemaUpgradeQuery {
       + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME) + "." + CommonRepoUtils.escapeColumnName(COLUMN_SQI_FORM)
+ " TO " + CommonRepoUtils.escapeColumnName(COLUMN_SQI_CONFIG);
 
   public static final String QUERY_UPGRADE_ADD_TABLE_SQ_INPUT_CONSTRAINT = "ALTER TABLE "
-      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME) + " ADD CONSTRAINT
" + CONSTRAINT_SQI_SQ_CFG + " " + "FOREIGN KEY ("
-      + CommonRepoUtils.escapeColumnName(COLUMN_SQI_CONFIG) + ") " + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP,
TABLE_SQ_CONFIG_NAME) + " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_ID) + ")";
+      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME) + " ADD CONSTRAINT
" + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQI_SQ_CFG) + " " + "FOREIGN
KEY ("
+      + CommonRepoUtils.escapeColumnName(COLUMN_SQI_CONFIG) + ") REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP,
TABLE_SQ_CONFIG_NAME) + " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_ID) + ")";
 
   // column rename and constraint add for SQ_JOB ( from and to link)
   public static final String QUERY_UPGRADE_RENAME_TABLE_SQ_JOB_COLUMN_1 = "RENAME COLUMN
"
@@ -381,21 +381,21 @@ public final class DerbySchemaUpgradeQuery {
       + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + "." + CommonRepoUtils.escapeColumnName(COLUMN_SQB_TO_CONNECTION)
+ " TO " + CommonRepoUtils.escapeColumnName(COLUMN_SQB_TO_LINK);
 
   public static final String QUERY_UPGRADE_ADD_TABLE_SQ_JOB_CONSTRAINT_FROM = "ALTER TABLE
"
-      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + " ADD CONSTRAINT
" + CONSTRAINT_SQB_SQ_LNK_FROM + " FOREIGN KEY ("
+      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + " ADD CONSTRAINT
" + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQB_SQ_LNK_FROM) + " FOREIGN
KEY ("
       + CommonRepoUtils.escapeColumnName(COLUMN_SQB_FROM_LINK) + ") REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP,
TABLE_SQ_LINK_NAME) + " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID) + ")";
 
   public static final String QUERY_UPGRADE_ADD_TABLE_SQ_JOB_CONSTRAINT_TO = "ALTER TABLE
"
-      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + " ADD CONSTRAINT
" + CONSTRAINT_SQB_SQ_LNK_TO + " FOREIGN KEY ("
+      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + " ADD CONSTRAINT
" + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQB_SQ_LNK_TO) + " 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_UPGRADE_TABLE_SQ_JOB_ADD_UNIQUE_CONSTRAINT_NAME = "ALTER
TABLE "
-      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + " ADD CONSTRAINT
" + CONSTRAINT_SQB_NAME_UNIQUE + " UNIQUE ("
+      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_JOB_NAME) + " ADD CONSTRAINT
" + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQB_NAME_UNIQUE) + " UNIQUE
("
       + CommonRepoUtils.escapeColumnName(COLUMN_SQB_NAME) + ")";
 
   public static final String QUERY_UPGRADE_TABLE_SQ_LINK_ADD_UNIQUE_CONSTRAINT_NAME = "ALTER
TABLE "
       + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME)
       + " ADD CONSTRAINT "
-      + CONSTRAINT_SQ_LNK_NAME_UNIQUE
+      + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQ_LNK_NAME_UNIQUE)
       + " UNIQUE ("
       + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_NAME) + ")";
 
@@ -403,15 +403,15 @@ public final class DerbySchemaUpgradeQuery {
 
   // drop the SQ_CONFIG FK for connector table
   public static final String QUERY_UPGRADE_DROP_TABLE_SQ_CONFIG_CONNECTOR_CONSTRAINT = "ALTER
TABLE "
-      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIG_NAME) + " DROP CONSTRAINT
" + CONSTRAINT_SQ_CFG_SQC;
+      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIG_NAME) + " DROP CONSTRAINT
" + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQ_CFG_SQC);
 
   // drop the SQ_LINK FK for connector table
   public static final String QUERY_UPGRADE_DROP_TABLE_SQ_LINK_CONSTRAINT = "ALTER TABLE "
-      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + " DROP CONSTRAINT
" + CONSTRAINT_SQ_LNK_SQC;
+      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + " DROP CONSTRAINT
" + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQ_LNK_SQC);
 
   // drop the SQ_CONNECTOR_DIRECTION FK for connector table
   public static final String QUERY_UPGRADE_DROP_TABLE_SQ_CONNECTOR_DIRECTION_CONSTRAINT =
"ALTER TABLE "
-      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONNECTOR_DIRECTIONS_NAME) +
" DROP CONSTRAINT " + CONSTRAINT_SQCD_SQC;
+      + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONNECTOR_DIRECTIONS_NAME) +
" DROP CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQCD_SQC);
 
   // rename
   public static final String QUERY_UPGRADE_RENAME_TABLE_SQ_CONNECTOR_TO_SQ_CONFIGURABLE =
"RENAME TABLE "
@@ -431,7 +431,7 @@ public final class DerbySchemaUpgradeQuery {
   public static final String QUERY_UPGRADE_ADD_TABLE_SQ_CONFIG_CONFIGURABLE_CONSTRAINT =
"ALTER TABLE "
       + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIG_NAME)
       + " ADD CONSTRAINT "
-      + CONSTRAINT_SQ_CFG_SQC
+      + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQ_CFG_SQC)
       + " "
       + "FOREIGN KEY ("
       + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_CONFIGURABLE)
@@ -445,7 +445,7 @@ public final class DerbySchemaUpgradeQuery {
   public static final String QUERY_UPGRADE_ADD_TABLE_SQ_LINK_CONFIGURABLE_CONSTRAINT = "ALTER
TABLE "
       + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME)
       + " ADD CONSTRAINT "
-      + CONSTRAINT_SQ_LNK_SQC
+      + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQ_LNK_SQC)
       + " "
       + "FOREIGN KEY ("
       + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_CONFIGURABLE)
@@ -459,7 +459,7 @@ public final class DerbySchemaUpgradeQuery {
   public static final String QUERY_UPGRADE_ADD_TABLE_SQ_CONNECTOR_DIRECTION_CONSTRAINT =
"ALTER TABLE "
       + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONNECTOR_DIRECTIONS_NAME)
       + " ADD CONSTRAINT "
-      + CONSTRAINT_SQCD_SQC
+      + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQCD_SQC)
       + " "
       + "FOREIGN KEY ("
       + CommonRepoUtils.escapeColumnName(COLUMN_SQCD_CONNECTOR)
@@ -470,7 +470,7 @@ public final class DerbySchemaUpgradeQuery {
 
  // add the constraints back for SQ_CONNECTOR_DIRECTION
   public static final String QUERY_UPGRADE_ADD_TABLE_SQ_CONNECTOR_DIRECTION_CONFIGURABLE_CONSTRAINT
= "ALTER TABLE "
-     + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + " ADD CONSTRAINT
" + CONSTRAINT_SQCD_SQC + " "
+     + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + " ADD CONSTRAINT
" + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQCD_SQC) + " "
        + "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQCD_CONNECTOR) + ") "
          + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIGURABLE_NAME)
+ " (" + CommonRepoUtils.escapeColumnName(COLUMN_SQC_ID) + ")";
 
@@ -483,14 +483,14 @@ public final class DerbySchemaUpgradeQuery {
   public static final String QUERY_UPGRADE_TABLE_SQ_CONFIGURABLE_ADD_UNIQUE_CONSTRAINT_NAME
= "ALTER TABLE "
       + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIGURABLE_NAME)
       + " ADD CONSTRAINT "
-      + CONSTRAINT_SQ_CONFIGURABLE_UNIQUE
+      + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQ_CONFIGURABLE_UNIQUE)
       + " UNIQUE (" + CommonRepoUtils.escapeColumnName(COLUMN_SQC_NAME) + ")";
 
   // add unique constraint on the config table for name and type and configurableId
   public static final String QUERY_UPGRADE_TABLE_SQ_CONFIG_ADD_UNIQUE_CONSTRAINT_NAME_TYPE_AND_CONFIGURABLE_ID
= "ALTER TABLE "
       + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_CONFIG_NAME)
       + " ADD CONSTRAINT "
-      + CONSTRAINT_SQ_CONFIG_UNIQUE
+      + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQ_CONFIG_UNIQUE)
       + " UNIQUE ("
       + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_NAME) + ", " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_TYPE)
+ ", " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_CFG_CONFIGURABLE) + ")";
 
@@ -498,7 +498,7 @@ public final class DerbySchemaUpgradeQuery {
   public static final String QUERY_UPGRADE_TABLE_SQ_INPUT_ADD_UNIQUE_CONSTRAINT_NAME_TYPE_AND_CONFIG_ID
= "ALTER TABLE "
       + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME)
       + " ADD CONSTRAINT "
-      + CONSTRAINT_SQ_INPUT_UNIQUE
+      + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQ_INPUT_UNIQUE)
       + " UNIQUE ("
       + CommonRepoUtils.escapeColumnName(COLUMN_SQI_NAME) + ", " + CommonRepoUtils.escapeColumnName(COLUMN_SQI_TYPE)
+ ", " + CommonRepoUtils.escapeColumnName(COLUMN_SQI_CONFIG) + ")";
 


Mime
View raw message