You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ja...@apache.org on 2014/10/14 05:36:16 UTC

[3/3] git commit: SQOOP-1566: Sqoop2: Fix the upgrade logic for SQOOP-1498

SQOOP-1566: Sqoop2: Fix the upgrade logic for SQOOP-1498

(Veena Basavaraj via Jarek Jarcec Cecho)


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

Branch: refs/heads/sqoop2
Commit: 6ae93e6ad846228bf56b8135ba83d1987c789dcf
Parents: b345b46
Author: Jarek Jarcec Cecho <ja...@apache.org>
Authored: Mon Oct 13 20:35:34 2014 -0700
Committer: Jarek Jarcec Cecho <ja...@apache.org>
Committed: Mon Oct 13 20:35:34 2014 -0700

----------------------------------------------------------------------
 .../apache/sqoop/repository/JdbcRepository.java |  16 +-
 .../sqoop/repository/JdbcRepositoryHandler.java |  63 +-
 .../org/apache/sqoop/repository/Repository.java |  48 +-
 .../sqoop/repository/RepositoryError.java       |   2 +-
 .../sqoop/repository/RepositoryManager.java     |  19 +-
 .../sqoop/repository/TestJdbcRepository.java    |  69 +-
 .../repository/derby/DerbyRepoConstants.java    |  11 +-
 .../sqoop/repository/derby/DerbyRepoError.java  |   2 +-
 .../derby/DerbyRepositoryHandler.java           | 235 +++---
 .../repository/derby/DerbySchemaConstants.java  | 176 ++--
 .../repository/derby/DerbySchemaQuery.java      | 806 +++++++++++--------
 .../sqoop/repository/derby/DerbyTestCase.java   | 265 +++---
 .../repository/derby/TestConnectorHandling.java |  16 +-
 .../repository/derby/TestDriverHandling.java    |  15 +-
 .../sqoop/repository/derby/TestInputTypes.java  |  29 +-
 .../sqoop/repository/derby/TestInternals.java   | 149 ----
 .../sqoop/repository/derby/TestJobHandling.java |  38 +-
 .../repository/derby/TestLinkHandling.java      |  35 +-
 .../derby/TestRespositorySchemaUpgrade.java     | 104 +++
 .../derby/TestSubmissionHandling.java           |  11 +-
 20 files changed, 1201 insertions(+), 908 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/6ae93e6a/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java b/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
index 3ade247..f06fd0c 100644
--- a/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/JdbcRepository.java
@@ -123,12 +123,12 @@ public class JdbcRepository extends Repository {
    * {@inheritDoc}
    */
   @Override
-  public void createOrUpdateInternals() {
+  public void createOrUpgradeRepository() {
     doWithConnection(new DoWithConnection() {
       @Override
       public Object doIt(Connection conn) throws Exception {
         LOG.info("Creating repository schema objects");
-        handler.createOrUpdateInternals(conn);
+        handler.createOrUpgradeRepository(conn);
         return null;
       }
     });
@@ -138,11 +138,11 @@ public class JdbcRepository extends Repository {
    * {@inheritDoc}
    */
   @Override
-  public boolean haveSuitableInternals() {
+  public boolean isRespositorySuitableForUse() {
     return (Boolean) doWithConnection(new DoWithConnection() {
       @Override
       public Object doIt(Connection conn) throws Exception {
-        return handler.haveSuitableInternals(conn);
+        return handler.isRespositorySuitableForUse(conn);
       }
     });
   }
@@ -652,23 +652,23 @@ public class JdbcRepository extends Repository {
    * {@inheritDoc}
    */
   @Override
-  protected void updateConnector(final MConnector newConnector,
+  protected void upgradeConnector(final MConnector newConnector,
     RepositoryTransaction tx) {
     doWithConnection(new DoWithConnection() {
       @Override
       public Object doIt(Connection conn) throws Exception {
-        handler.updateConnector(newConnector, conn);
+        handler.upgradeConnector(newConnector, conn);
         return null;
       }
     }, (JdbcRepositoryTransaction) tx);
   }
 
 
-  protected void updateDriver(final MDriver mDriver, RepositoryTransaction tx) {
+  protected void upgradeDriver(final MDriver mDriver, RepositoryTransaction tx) {
     doWithConnection(new DoWithConnection() {
       @Override
       public Object doIt(Connection conn) throws Exception {
-        handler.updateDriver(mDriver, conn);
+        handler.upgradeDriver(mDriver, conn);
         return null;
       }
     }, (JdbcRepositoryTransaction) tx);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/6ae93e6a/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java b/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
index 97de893..5a8e026 100644
--- a/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
+++ b/core/src/main/java/org/apache/sqoop/repository/JdbcRepositoryHandler.java
@@ -89,35 +89,35 @@ public abstract class JdbcRepositoryHandler {
     Connection conn);
 
   /**
-   * Update the connector with the new data supplied in the <tt>newConnector</tt>.
-   * Also Update all forms associated with this connector in the repository
-   * with the forms specified in <tt>mConnector</tt>. <tt>mConnector </tt> must
-   * minimally have the connectorID and all required forms (including ones
+   * Upgrade the connector with the new data supplied in the <tt>newConnector</tt>.
+   * Also Update all configs associated with this connector in the repository
+   * with the configs specified in <tt>mConnector</tt>. <tt>mConnector </tt> must
+   * minimally have the configurableID and all required configs (including ones
    * which may not have changed). After this operation the repository is
-   * guaranteed to only have the new forms specified in this object.
+   * guaranteed to only have the new configs specified in this object.
    *
    * @param mConnector The new data to be inserted into the repository for
    *                     this connector.
    * @param conn JDBC link for querying repository
    */
 
-  public abstract void updateConnector(MConnector mConnector, Connection conn);
+  public abstract void upgradeConnector(MConnector mConnector, Connection conn);
 
 
   /**
-   * Update the driverConfig with the new data supplied in the
-   * <tt>mDriverConfig</tt>.
-   * Also Update all forms in the repository
-   * with the forms specified in <tt>mDriverConfig</tt>. <tt>mDriverConfig </tt> must
-   * minimally have the connectorID and all required forms (including ones
+   * Upgrade the driver with the new data supplied in the
+   * <tt>mDriver</tt>.
+   * Also Update all configs in the repository
+   * with the configs specified in <tt>mDriverConfig</tt>. <tt>mDriver </tt> must
+   * minimally have the configurableID and all required configs (including ones
    * which may not have changed). After this operation the repository is
-   * guaranteed to only have the new forms specified in this object.
+   * guaranteed to only have the new configs specified in this object.
    *
    * @param mDriver The new data to be inserted into the repository for
    *                     the driverConfig.
    * @param conn JDBC link for querying repository
    */
-  public abstract void updateDriver(MDriver mDriver, Connection conn);
+  public abstract void upgradeDriver(MDriver mDriver, Connection conn);
 
 
   /**
@@ -135,30 +135,32 @@ public abstract class JdbcRepositoryHandler {
    * Save driver config into repository. Driver config  should not be already
    * registered or present in the repository.
    *
-   * @param driverConfig Driver config that should be registered.
+   * @param mDriver Driver config that should be registered.
    * @param conn JDBC link for querying repository.
    */
-  public abstract void registerDriver(MDriver driverConfig, Connection conn);
+  public abstract void registerDriver(MDriver mDriver, Connection conn);
 
   /**
-   * Return true if repository tables exists and are suitable for use.
+   * Create or update the repository schema structures.
    *
-   * This method should return false in case that the tables do exists, but
-   * are not suitable for use or if they requires upgrade.
-   *
-   * @return Boolean values if internal structures are suitable for use
+   * This method will be called from the Sqoop server if enabled via a config
+   * {@link RepoConfigurationConstants#SYSCFG_REPO_SCHEMA_IMMUTABLE} to enforce
+   * changing the repository schema structure or explicitly via the
+   * {@link UpgradeTool} Repository should not change its schema structure
+   * outside of this method. This method must be no-op in case that the schema
+   * structure do not need any upgrade.
+   * @param conn JDBC link for querying repository
    */
-  public abstract boolean haveSuitableInternals(Connection conn);
+  public abstract void createOrUpgradeRepository(Connection conn);
 
   /**
-   * Create or update tables in the repository.
-   *
-   * This method will be called only if Sqoop server is enabled with changing
-   * repository on disk structures. Repository should not change its disk structures
-   * outside of this method. This method must be no-op in case that the structures
-   * do not need any maintenance.
+   * Return true if internal repository structures exists and are suitable for use.
+   * This method should return false in case that the structures do exists, but
+   * are not suitable to use i.e corrupted as part of the upgrade
+   * @param conn JDBC link for querying repository
+   * @return Boolean values if internal structures are suitable for use
    */
-  public abstract void createOrUpdateInternals(Connection conn);
+  public abstract boolean isRespositorySuitableForUse(Connection conn);
 
   /**
    * Termination callback for repository.
@@ -398,6 +400,5 @@ public abstract class JdbcRepositoryHandler {
    * @param conn Connection to the repository
    * @return Most recent submission
    */
-  public abstract MSubmission findSubmissionLastForJob(long jobId,
-    Connection conn);
-}
+  public abstract MSubmission findSubmissionLastForJob(long jobId, Connection conn);
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/6ae93e6a/core/src/main/java/org/apache/sqoop/repository/Repository.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/Repository.java b/core/src/main/java/org/apache/sqoop/repository/Repository.java
index 95c7a4d..74a9e12 100644
--- a/core/src/main/java/org/apache/sqoop/repository/Repository.java
+++ b/core/src/main/java/org/apache/sqoop/repository/Repository.java
@@ -58,28 +58,29 @@ public abstract class Repository {
   public abstract RepositoryTransaction getTransaction();
 
   /**
-   * Create or update disk data structures.
+   * Create or update the repository schema structures.
    *
-   * This method will be called only if Sqoop server is enabled with changing
-   * repository on disk structures. Repository should not change its disk structures
-   * outside of this method. This method must be no-op in case that the structures
-   * do not need any maintenance.
+   * This method will be called from the Sqoop server if enabled via a config
+   * {@link RepoConfigurationConstants#SYSCFG_REPO_SCHEMA_IMMUTABLE} to enforce
+   * changing the repository schema structure or explicitly via the
+   * {@link UpgradeTool} Repository should not change its schema structure
+   * outside of this method. This method must be no-op in case that the schema
+   * structure do not need any upgrade.
    */
-  public abstract void createOrUpdateInternals();
+  public abstract void createOrUpgradeRepository();
 
   /**
    * Return true if internal repository structures exists and are suitable for use.
-   *
    * This method should return false in case that the structures do exists, but
-   * are not suitable for use or if they requires upgrade.
+   * are not suitable to use i.e corrupted as part of the upgrade
    *
    * @return Boolean values if internal structures are suitable for use
    */
-  public abstract boolean haveSuitableInternals();
+  public abstract boolean isRespositorySuitableForUse();
 
   /**
    * Registers given connector in the repository and return registered
-   * variant. This method might return an exception in case that
+   * variant.This method might return an exception in case that
    * given connector are already registered with different structure
    *
    * @param mConnector the connector to be registered
@@ -305,7 +306,7 @@ public abstract class Repository {
    * <tt>newConnector</tt>. Also Update all configs associated with this
    * connector in the repository with the configs specified in
    * <tt>mConnector</tt>. <tt>mConnector </tt> must
-   * minimally have the connectorID and all required configs (including ones
+   * minimally have the configurableID and all required configs (including ones
    * which may not have changed). After this operation the repository is
    * guaranteed to only have the new configs specified in this object.
    *
@@ -316,25 +317,25 @@ public abstract class Repository {
    *           method will not call begin, commit,
    *           rollback or close on this transaction.
    */
-  protected abstract void updateConnector(MConnector newConnector, RepositoryTransaction tx);
+  protected abstract void upgradeConnector(MConnector newConnector, RepositoryTransaction tx);
 
   /**
-   * Update the driver with the new data supplied in the
-   * <tt>mDriverConfig</tt>. Also Update all configs associated with the driverConfig
+   * Upgrade the driver with the new data supplied in the
+   * <tt>mDriver</tt>. Also Update all configs associated with the driver
    * in the repository with the configs specified in
-   * <tt>mDriverConfig</tt>. <tt>mDriverConfig </tt> must
-   * minimally have the connectorID and all required configs (including ones
+   * <tt>mDriver</tt>. <tt>mDriver </tt> must
+   * minimally have the configurableID and all required configs (including ones
    * which may not have changed). After this operation the repository is
    * guaranteed to only have the new configs specified in this object.
    *
-   * @param mDriver The new data to be inserted into the repository for
+   * @param newDriver The new data to be inserted into the repository for
    *                     the driverConfig.
    * @param tx The repository transaction to use to push the data to the
    *           repository. If this is null, a new transaction will be created.
    *           method will not call begin, commit,
    *           rollback or close on this transaction.
    */
-  protected abstract void updateDriver(MDriver mDriver, RepositoryTransaction tx);
+  protected abstract void upgradeDriver(MDriver newDriver, RepositoryTransaction tx);
 
   /**
    * Delete all inputs for a job
@@ -417,7 +418,7 @@ public abstract class Repository {
       tx = getTransaction();
       tx.begin();
       deletelinksAndJobs(linksByConnector, jobsByConnector, tx);
-      updateConnector(newConnector, tx);
+      upgradeConnector(newConnector, tx);
       for (MLink oldLink : linksByConnector) {
         // Make a new copy of the configs
         List<MConfig> linkConfig = newConnector.getLinkConfig().clone(false).getConfigs();
@@ -495,8 +496,7 @@ public abstract class Repository {
     LOG.info("Upgrading driver");
     RepositoryTransaction tx = null;
     try {
-      RepositoryUpgrader driverConfigUpgrader = Driver.getInstance()
-        .getDriverConfigRepositoryUpgrader();
+      RepositoryUpgrader upgrader = Driver.getInstance().getDriverConfigRepositoryUpgrader();
       List<MJob> jobs = findJobs();
 
       Validator validator = Driver.getInstance().getValidator();
@@ -506,13 +506,13 @@ public abstract class Repository {
       tx = getTransaction();
       tx.begin();
       deleteJobs(jobs, tx);
-      updateDriver(driver, tx);
+      upgradeDriver(driver, tx);
 
       for (MJob job : jobs) {
         // Make a new copy of the configs
         MDriverConfig driverConfig = driver.getDriverConfig().clone(false);
         MDriver newDriver = new MDriver(driverConfig, DriverBean.CURRENT_DRIVER_VERSION);
-        driverConfigUpgrader.upgrade(job.getDriverConfig(), newDriver.getDriverConfig());
+        upgrader.upgrade(job.getDriverConfig(), newDriver.getDriverConfig());
         MJob newJob = new MJob(job, job.getFromJobConfig(), job.getToJobConfig(), newDriver.getDriverConfig());
 
         // Transform config structures to objects for validations
@@ -558,4 +558,4 @@ public abstract class Repository {
       LOG.error("\t" + entry.getKey() + ": " + entry.getValue());
     }
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/6ae93e6a/core/src/main/java/org/apache/sqoop/repository/RepositoryError.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/RepositoryError.java b/core/src/main/java/org/apache/sqoop/repository/RepositoryError.java
index 0c93b50..f684e85 100644
--- a/core/src/main/java/org/apache/sqoop/repository/RepositoryError.java
+++ b/core/src/main/java/org/apache/sqoop/repository/RepositoryError.java
@@ -30,7 +30,7 @@ public enum RepositoryError implements ErrorCode {
   REPO_0001("Invalid repository provider specified"),
 
   /** Repository on disk structures are not suitable for use */
-  REPO_0002("Repository structures are not initialized or requires upgrade"),
+  REPO_0002("Repository structures are not in suitable state, might require upgrade"),
 
   // JDBC Repository Errors: Prefix JDBCREP
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/6ae93e6a/core/src/main/java/org/apache/sqoop/repository/RepositoryManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/sqoop/repository/RepositoryManager.java b/core/src/main/java/org/apache/sqoop/repository/RepositoryManager.java
index c2f8505..6b481b8 100644
--- a/core/src/main/java/org/apache/sqoop/repository/RepositoryManager.java
+++ b/core/src/main/java/org/apache/sqoop/repository/RepositoryManager.java
@@ -58,10 +58,12 @@ public class RepositoryManager implements Reconfigurable {
   }
 
   /**
-   * Allows to set instance in case that it's need.
+   * Allows to set instance
    *
-   * This method should not be normally used as the default instance should be sufficient. One target
+   * This method should not be normally used since the default instance should be sufficient. One target
    * user use case for this method are unit tests.
+   * NOTE: Ideally this should not have been a public method, default package access should have been sufficient if tests were
+   * written keeping this in mind
    *
    * @param newInstance New instance
    */
@@ -100,8 +102,7 @@ public class RepositoryManager implements Reconfigurable {
       LOG.trace("Repository provider: " + repoProviderClassName);
     }
 
-    Class<?> repoProviderClass =
-        ClassUtils.loadClass(repoProviderClassName);
+    Class<?> repoProviderClass = ClassUtils.loadClass(repoProviderClassName);
 
     if (repoProviderClass == null) {
       throw new SqoopException(RepositoryError.REPO_0001,
@@ -118,17 +119,19 @@ public class RepositoryManager implements Reconfigurable {
     provider.initialize(context);
 
     if(!immutableRepository) {
-      LOG.info("Creating or update respository internals at bootup");
-      provider.getRepository().createOrUpdateInternals();
+      LOG.info("Creating or updating respository at bootup");
+      provider.getRepository().createOrUpgradeRepository();
     }
 
-    if(!provider.getRepository().haveSuitableInternals()) {
+    // NOTE: There are scenarios where a repository upgrade/ changes may happen outside of the
+    // server bootup lifecyle. Hence always check/ verify for the repository sanity before marking the repo manager ready
+    if(!provider.getRepository().isRespositorySuitableForUse()) {
       throw new SqoopException(RepositoryError.REPO_0002);
     }
 
     SqoopConfiguration.getInstance().getProvider().registerListener(new CoreConfigurationListener(this));
 
-    LOG.info("Repository initialized: OK");
+    LOG.info("Repository Manager initialized: OK");
   }
 
   public synchronized void destroy() {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/6ae93e6a/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java b/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
index e6e4760..34bd8a5 100644
--- a/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
+++ b/core/src/test/java/org/apache/sqoop/repository/TestJdbcRepository.java
@@ -46,7 +46,6 @@ import org.apache.sqoop.connector.ConnectorManager;
 import org.apache.sqoop.connector.spi.RepositoryUpgrader;
 import org.apache.sqoop.connector.spi.SqoopConnector;
 import org.apache.sqoop.driver.Driver;
-import org.apache.sqoop.driver.configuration.DriverConfiguration;
 import org.apache.sqoop.json.DriverBean;
 import org.apache.sqoop.model.ConfigUtils;
 import org.apache.sqoop.model.ConfigurationClass;
@@ -66,6 +65,7 @@ import org.apache.sqoop.validation.Validator;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.InOrder;
+import org.mockito.Mockito;
 
 public class TestJdbcRepository {
 
@@ -219,8 +219,9 @@ public class TestJdbcRepository {
     when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(validRepoMock);
     when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
     when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
-    when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfigurationGroup.class);
-    when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(DriverConfiguration.class);
+    when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyLinkConfiguration.class);
+    when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(
+        EmptyJobConfiguration.class);
     when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
 
     // prepare the links and jobs
@@ -232,7 +233,7 @@ public class TestJdbcRepository {
     doReturn(jobList).when(repoSpy).findJobsForConnector(anyLong());
     doNothing().when(repoSpy).updateLink(any(MLink.class), any(RepositoryTransaction.class));
     doNothing().when(repoSpy).updateJob(any(MJob.class), any(RepositoryTransaction.class));
-    doNothing().when(repoSpy).updateConnector(any(MConnector.class), any(RepositoryTransaction.class));
+    doNothing().when(repoSpy).upgradeConnector(any(MConnector.class), any(RepositoryTransaction.class));
 
     repoSpy.upgradeConnector(oldConnector, newConnector);
 
@@ -248,7 +249,7 @@ public class TestJdbcRepository {
     repoOrder.verify(repoSpy, times(1)).deleteJobInputs(2, repoTransactionMock);
     repoOrder.verify(repoSpy, times(1)).deleteLinkInputs(1, repoTransactionMock);
     repoOrder.verify(repoSpy, times(1)).deleteLinkInputs(2, repoTransactionMock);
-    repoOrder.verify(repoSpy, times(1)).updateConnector(any(MConnector.class), any(RepositoryTransaction.class));
+    repoOrder.verify(repoSpy, times(1)).upgradeConnector(any(MConnector.class), any(RepositoryTransaction.class));
     repoOrder.verify(repoSpy, times(2)).updateLink(any(MLink.class), any(RepositoryTransaction.class));
     repoOrder.verify(repoSpy, times(4)).updateJob(any(MJob.class), any(RepositoryTransaction.class));
     repoOrder.verifyNoMoreInteractions();
@@ -277,14 +278,13 @@ public class TestJdbcRepository {
     when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(validRepoMock);
     when(driverMock.getValidator()).thenReturn(validatorMock);
     when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
-    when(driverMock.getDriverConfigurationGroupClass()).thenReturn(EmptyConfigurationGroup.class);
-
+    when(driverMock.getDriverConfigurationGroupClass()).thenReturn(EmptyJobConfiguration.class);
     List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
 
     doReturn(jobList).when(repoSpy).findJobs();
     doNothing().when(repoSpy).updateLink(any(MLink.class), any(RepositoryTransaction.class));
     doNothing().when(repoSpy).updateJob(any(MJob.class), any(RepositoryTransaction.class));
-    doNothing().when(repoSpy).updateDriver(any(MDriver.class), any(RepositoryTransaction.class));
+    doNothing().when(repoSpy).upgradeDriver(any(MDriver.class), any(RepositoryTransaction.class));
 
     repoSpy.upgradeDriver(newDriverConfig);
 
@@ -297,7 +297,7 @@ public class TestJdbcRepository {
     repoOrder.verify(repoSpy, times(1)).getTransaction();
     repoOrder.verify(repoSpy, times(1)).deleteJobInputs(1, repoTransactionMock);
     repoOrder.verify(repoSpy, times(1)).deleteJobInputs(2, repoTransactionMock);
-    repoOrder.verify(repoSpy, times(1)).updateDriver(any(MDriver.class), any(RepositoryTransaction.class));
+    repoOrder.verify(repoSpy, times(1)).upgradeDriver(any(MDriver.class), any(RepositoryTransaction.class));
     repoOrder.verify(repoSpy, times(2)).updateJob(any(MJob.class), any(RepositoryTransaction.class));
     repoOrder.verifyNoMoreInteractions();
     txOrder.verify(repoTransactionMock, times(1)).begin();
@@ -322,13 +322,12 @@ public class TestJdbcRepository {
     when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(invalidRepoMock);
     when(driverMock.getValidator()).thenReturn(validatorMock);
     when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
-    when(driverMock.getDriverConfigurationGroupClass()).thenReturn(EmptyConfigurationGroup.class);
-
+    when(driverMock.getDriverConfigurationGroupClass()).thenReturn(EmptyJobConfiguration.class);
     List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
 
     doReturn(jobList).when(repoSpy).findJobs();
     doNothing().when(repoSpy).updateJob(any(MJob.class), any(RepositoryTransaction.class));
-    doNothing().when(repoSpy).updateDriver(any(MDriver.class), any(RepositoryTransaction.class));
+    doNothing().when(repoSpy).upgradeDriver(any(MDriver.class), any(RepositoryTransaction.class));
 
     try {
       repoSpy.upgradeDriver(newDriverConfig);
@@ -344,7 +343,7 @@ public class TestJdbcRepository {
       repoOrder.verify(repoSpy, times(1)).getTransaction();
       repoOrder.verify(repoSpy, times(1)).deleteJobInputs(1, repoTransactionMock);
       repoOrder.verify(repoSpy, times(1)).deleteJobInputs(2, repoTransactionMock);
-      repoOrder.verify(repoSpy, times(1)).updateDriver(any(MDriver.class), any(RepositoryTransaction.class));
+      repoOrder.verify(repoSpy, times(1)).upgradeDriver(any(MDriver.class), any(RepositoryTransaction.class));
       repoOrder.verifyNoMoreInteractions();
       txOrder.verify(repoTransactionMock, times(1)).begin();
       txOrder.verify(repoTransactionMock, times(1)).rollback();
@@ -524,7 +523,7 @@ public class TestJdbcRepository {
 
     SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
         "update connector error.");
-    doThrow(exception).when(repoHandlerMock).updateConnector(any(MConnector.class), any(Connection.class));
+    doThrow(exception).when(repoHandlerMock).upgradeConnector(any(MConnector.class), any(Connection.class));
 
     try {
       repoSpy.upgradeConnector(oldConnector, newConnector);
@@ -534,7 +533,7 @@ public class TestJdbcRepository {
       verify(repoHandlerMock, times(1)).findJobsForConnector(anyLong(), any(Connection.class));
       verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
       verify(repoHandlerMock, times(2)).deleteLinkInputs(anyLong(), any(Connection.class));
-      verify(repoHandlerMock, times(1)).updateConnector(any(MConnector.class), any(Connection.class));
+      verify(repoHandlerMock, times(1)).upgradeConnector(any(MConnector.class), any(Connection.class));
       verifyNoMoreInteractions(repoHandlerMock);
       return ;
     }
@@ -556,8 +555,8 @@ public class TestJdbcRepository {
     when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(validRepoMock);
     when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
     when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
-    when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfigurationGroup.class);
-    when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(DriverConfiguration.class);
+    when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyLinkConfiguration.class);
+    when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(EmptyJobConfiguration.class);
     when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
 
     List<MLink> linkList = links(link(1,1), link(2,1));
@@ -566,7 +565,7 @@ public class TestJdbcRepository {
     doReturn(jobList).when(repoHandlerMock).findJobsForConnector(anyLong(), any(Connection.class));
     doNothing().when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
     doNothing().when(repoHandlerMock).deleteLinkInputs(anyLong(), any(Connection.class));
-    doNothing().when(repoHandlerMock).updateConnector(any(MConnector.class), any(Connection.class));
+    doNothing().when(repoHandlerMock).upgradeConnector(any(MConnector.class), any(Connection.class));
     doReturn(true).when(repoHandlerMock).existsLink(anyLong(), any(Connection.class));
 
     SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
@@ -581,7 +580,7 @@ public class TestJdbcRepository {
       verify(repoHandlerMock, times(1)).findJobsForConnector(anyLong(), any(Connection.class));
       verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
       verify(repoHandlerMock, times(2)).deleteLinkInputs(anyLong(), any(Connection.class));
-      verify(repoHandlerMock, times(1)).updateConnector(any(MConnector.class), any(Connection.class));
+      verify(repoHandlerMock, times(1)).upgradeConnector(any(MConnector.class), any(Connection.class));
       verify(repoHandlerMock, times(1)).existsLink(anyLong(), any(Connection.class));
       verify(repoHandlerMock, times(1)).updateLink(any(MLink.class), any(Connection.class));
       verifyNoMoreInteractions(repoHandlerMock);
@@ -605,8 +604,8 @@ public class TestJdbcRepository {
     when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(validRepoMock);
     when(sqconnector.getConfigValidator()).thenReturn(validatorMock);
     when(sqconnector.getRepositoryUpgrader()).thenReturn(upgraderMock);
-    when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyConfigurationGroup.class);
-    when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(DriverConfiguration.class);
+    when(sqconnector.getLinkConfigurationClass()).thenReturn(EmptyLinkConfiguration.class);
+    when(sqconnector.getJobConfigurationClass(any(Direction.class))).thenReturn(EmptyJobConfiguration.class);
     when(connectorMgrMock.getConnector(anyString())).thenReturn(sqconnector);
 
     List<MLink> linkList = links(link(1,1), link(2,1));
@@ -615,7 +614,7 @@ public class TestJdbcRepository {
     doReturn(jobList).when(repoHandlerMock).findJobsForConnector(anyLong(), any(Connection.class));
     doNothing().when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
     doNothing().when(repoHandlerMock).deleteLinkInputs(anyLong(), any(Connection.class));
-    doNothing().when(repoHandlerMock).updateConnector(any(MConnector.class), any(Connection.class));
+    doNothing().when(repoHandlerMock).upgradeConnector(any(MConnector.class), any(Connection.class));
     doNothing().when(repoHandlerMock).updateLink(any(MLink.class), any(Connection.class));
     doReturn(true).when(repoHandlerMock).existsLink(anyLong(), any(Connection.class));
     doReturn(true).when(repoHandlerMock).existsJob(anyLong(), any(Connection.class));
@@ -632,7 +631,7 @@ public class TestJdbcRepository {
       verify(repoHandlerMock, times(1)).findJobsForConnector(anyLong(), any(Connection.class));
       verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
       verify(repoHandlerMock, times(2)).deleteLinkInputs(anyLong(), any(Connection.class));
-      verify(repoHandlerMock, times(1)).updateConnector(any(MConnector.class), any(Connection.class));
+      verify(repoHandlerMock, times(1)).upgradeConnector(any(MConnector.class), any(Connection.class));
       verify(repoHandlerMock, times(2)).existsLink(anyLong(), any(Connection.class));
       verify(repoHandlerMock, times(2)).updateLink(any(MLink.class), any(Connection.class));
       verify(repoHandlerMock, times(1)).existsJob(anyLong(), any(Connection.class));
@@ -720,7 +719,7 @@ public class TestJdbcRepository {
 
     SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
         "update driverConfig entity error.");
-    doThrow(exception).when(repoHandlerMock).updateDriver(any(MDriver.class), any(Connection.class));
+    doThrow(exception).when(repoHandlerMock).upgradeDriver(any(MDriver.class), any(Connection.class));
 
     try {
       repoSpy.upgradeDriver(newDriverConfig);
@@ -728,7 +727,7 @@ public class TestJdbcRepository {
       assertEquals(ex.getMessage(), exception.getMessage());
       verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
       verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
-      verify(repoHandlerMock, times(1)).updateDriver(any(MDriver.class), any(Connection.class));
+      verify(repoHandlerMock, times(1)).upgradeDriver(any(MDriver.class), any(Connection.class));
       verifyNoMoreInteractions(repoHandlerMock);
       return ;
     }
@@ -749,12 +748,11 @@ public class TestJdbcRepository {
     when(validatorMock.validateConfigForJob(any(MJob.class))).thenReturn(validRepoMock);
     when(driverMock.getValidator()).thenReturn(validatorMock);
     when(driverMock.getDriverConfigRepositoryUpgrader()).thenReturn(upgraderMock);
-    when(driverMock.getDriverConfigurationGroupClass()).thenReturn(EmptyConfigurationGroup.class);
-
+    when(driverMock.getDriverConfigurationGroupClass()).thenReturn(EmptyJobConfiguration.class);
     List<MJob> jobList = jobs(job(1,1,1,1,1), job(2,1,1,2,1));
     doReturn(jobList).when(repoHandlerMock).findJobs(any(Connection.class));
     doNothing().when(repoHandlerMock).deleteJobInputs(anyLong(), any(Connection.class));
-    doNothing().when(repoHandlerMock).updateDriver(any(MDriver.class), any(Connection.class));
+    doNothing().when(repoHandlerMock).upgradeDriver(any(MDriver.class), any(Connection.class));
     doReturn(true).when(repoHandlerMock).existsJob(anyLong(), any(Connection.class));
 
     SqoopException exception = new SqoopException(RepositoryError.JDBCREPO_0000,
@@ -767,7 +765,7 @@ public class TestJdbcRepository {
       assertEquals(ex.getMessage(), exception.getMessage());
       verify(repoHandlerMock, times(1)).findJobs(any(Connection.class));
       verify(repoHandlerMock, times(2)).deleteJobInputs(anyLong(), any(Connection.class));
-      verify(repoHandlerMock, times(1)).updateDriver(any(MDriver.class), any(Connection.class));
+      verify(repoHandlerMock, times(1)).upgradeDriver(any(MDriver.class), any(Connection.class));
       verify(repoHandlerMock, times(1)).existsJob(anyLong(), any(Connection.class));
       verify(repoHandlerMock, times(1)).updateJob(any(MJob.class), any(Connection.class));
       verifyNoMoreInteractions(repoHandlerMock);
@@ -780,8 +778,8 @@ public class TestJdbcRepository {
   private MConnector connector(long connectorId, String version) {
     MConnector connector = new MConnector("A" + connectorId, "A" + connectorId, version + connectorId,
         new MLinkConfig(new LinkedList<MConfig>()),
-        new MFromConfig(ConfigUtils.toConfigs(FromJobConfigurationGroup.class)),
-        new MToConfig(ConfigUtils.toConfigs(ToJobConfigurationGroup.class)));
+        new MFromConfig(ConfigUtils.toConfigs(EmptyJobConfiguration.class)),
+        new MToConfig(ConfigUtils.toConfigs(EmptyJobConfiguration.class)));
     connector.setPersistenceId(connectorId);
     return connector;
   }
@@ -831,12 +829,9 @@ public class TestJdbcRepository {
   }
 
   @ConfigurationClass
-  public static class EmptyConfigurationGroup {
-  }
-  @ConfigurationClass
-  public static class FromJobConfigurationGroup {
+  public static class EmptyLinkConfiguration {
   }
   @ConfigurationClass
-  public static class ToJobConfigurationGroup {
+  public static class EmptyJobConfiguration {
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/6ae93e6a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoConstants.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoConstants.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoConstants.java
index 74e41df..40dcc49 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoConstants.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoConstants.java
@@ -21,9 +21,14 @@ public final class DerbyRepoConstants {
 
   public static final String CONF_PREFIX_DERBY = "derby.";
 
+  @Deprecated
+  // use only for the upgrade code should be removed soon
   public static final String SYSKEY_VERSION = "version";
 
-  public static final String SYSKEY_DRIVER_VERSION = "driver.version";
+  public static final String SYSKEY_DERBY_REPOSITORY_VERSION = "version";
+
+  // TOOD(VB): SQOOP-1557 move the driver config version to the SQ_CONFIGURABLE, IT SHOULD NOT BE HERE, nor stored in SYSTEM table
+  public static final String SYSKEY_DRIVER_CONFIG_VERSION = "driver.config.version";
 
   /**
    * Expected version of the repository structures.
@@ -43,9 +48,9 @@ public final class DerbyRepoConstants {
    * 4 - Version 1.99.4
    *     Changed to FROM/TO design.
    */
-  public static final int VERSION = 4;
+  public static final int LATEST_DERBY_REPOSITORY_VERSION = 4;
 
   private DerbyRepoConstants() {
     // Disable explicit object creation
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/6ae93e6a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java
index 0f0f7c4..3e4a4a9 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepoError.java
@@ -204,4 +204,4 @@ public enum DerbyRepoError implements ErrorCode {
   public String getMessage() {
     return message;
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/6ae93e6a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
index 10a7b1a..c888910 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbyRepositoryHandler.java
@@ -91,8 +91,6 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
    */
   private static final String CONNECTOR_HDFS = "hdfs-connector";
 
-  private static final String LINK_HDFS = "hdfs-link";
-
   private JdbcRepositoryContext repoContext;
 
   /**
@@ -288,12 +286,12 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
   }
 
   /**
-   * Detect version of underlying database structures.
+   * Detect version of underlying database structures
    *
    * @param conn JDBC Connection
    * @return
    */
-  public int detectVersion(Connection conn) {
+  public int detectRepositoryVersion(Connection conn) {
     ResultSet rs = null;
     PreparedStatement stmt = null;
 
@@ -308,7 +306,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
       }
       closeResultSets(rs);
 
-      LOG.debug("Detecting old version of repository");
+      LOG.debug("Detecting existing version of repository");
       boolean foundAll = true;
       for( String expectedTable : DerbySchemaConstants.tablesV1) {
         if(!tableNames.contains(expectedTable)) {
@@ -330,8 +328,11 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
 
     // Normal version detection, select and return the version
     try {
-      stmt = conn.prepareStatement(STMT_SELECT_SYSTEM);
-      stmt.setString(1, DerbyRepoConstants.SYSKEY_VERSION);
+      // NOTE: Since we can different types of version stored in system table, we renamed the
+      // key name for the repository version from "version" to "repository.version" for clarity
+      stmt = conn.prepareStatement(STMT_SELECT_DEPRECATED_OR_NEW_SYSTEM_VERSION);
+      stmt.setString(1, DerbyRepoConstants.SYSKEY_DERBY_REPOSITORY_VERSION);
+      stmt.setString(2, DerbyRepoConstants.SYSKEY_VERSION);
       rs = stmt.executeQuery();
 
       if(!rs.next()) {
@@ -359,7 +360,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
     PreparedStatement stmt = null;
     try {
       stmt = conn.prepareStatement(DerbySchemaQuery.STMT_SELECT_SYSTEM);
-      stmt.setString(1, DerbyRepoConstants.SYSKEY_DRIVER_VERSION);
+      stmt.setString(1, DerbyRepoConstants.SYSKEY_DRIVER_CONFIG_VERSION);
       rs = stmt.executeQuery();
       if(!rs.next()) {
         return null;
@@ -384,12 +385,12 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
     PreparedStatement stmt = null;
     try {
       stmt = conn.prepareStatement(STMT_DELETE_SYSTEM);
-      stmt.setString(1, DerbyRepoConstants.SYSKEY_DRIVER_VERSION);
+      stmt.setString(1, DerbyRepoConstants.SYSKEY_DRIVER_CONFIG_VERSION);
       stmt.executeUpdate();
       closeStatements(stmt);
 
       stmt = conn.prepareStatement(STMT_INSERT_SYSTEM);
-      stmt.setString(1, DerbyRepoConstants.SYSKEY_DRIVER_VERSION);
+      stmt.setString(1, DerbyRepoConstants.SYSKEY_DRIVER_CONFIG_VERSION);
       stmt.setString(2, version);
       stmt.executeUpdate();
     } catch (SQLException e) {
@@ -405,85 +406,136 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
    * {@inheritDoc}
    */
   @Override
-  public void createOrUpdateInternals(Connection conn) {
-    int version = detectVersion(conn);
+  public void createOrUpgradeRepository(Connection conn) {
 
-    if(version <= 0) {
+    int repositoryVersion = detectRepositoryVersion(conn);
+    if(repositoryVersion <= 0) {
       runQuery(QUERY_CREATE_SCHEMA_SQOOP, conn);
       runQuery(QUERY_CREATE_TABLE_SQ_CONNECTOR, conn);
-      runQuery(QUERY_CREATE_TABLE_SQ_CONFIG, conn);
+      runQuery(QUERY_CREATE_TABLE_SQ_FORM, conn);
       runQuery(QUERY_CREATE_TABLE_SQ_INPUT, conn);
-      runQuery(QUERY_CREATE_TABLE_SQ_LINK, conn);
+      runQuery(QUERY_CREATE_TABLE_SQ_CONNECTION, conn);
       runQuery(QUERY_CREATE_TABLE_SQ_JOB, conn);
-      runQuery(QUERY_CREATE_TABLE_SQ_LINK_INPUT, conn);
+      runQuery(QUERY_CREATE_TABLE_SQ_CONNECTION_INPUT, conn);
       runQuery(QUERY_CREATE_TABLE_SQ_JOB_INPUT, conn);
       runQuery(QUERY_CREATE_TABLE_SQ_SUBMISSION, conn);
       runQuery(QUERY_CREATE_TABLE_SQ_COUNTER_GROUP, conn);
       runQuery(QUERY_CREATE_TABLE_SQ_COUNTER, conn);
       runQuery(QUERY_CREATE_TABLE_SQ_COUNTER_SUBMISSION, conn);
     }
-    if(version <= 1) {
+    if(repositoryVersion <= 1) {
       runQuery(QUERY_CREATE_TABLE_SQ_SYSTEM, conn);
-      runQuery(QUERY_UPGRADE_TABLE_SQ_LINK_ADD_COLUMN_ENABLED, conn);
+      runQuery(QUERY_UPGRADE_TABLE_SQ_CONNECTION_ADD_COLUMN_ENABLED, conn);
       runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_ENABLED, conn);
-      runQuery(QUERY_UPGRADE_TABLE_SQ_LINK_ADD_COLUMN_CREATION_USER, conn);
-      runQuery(QUERY_UPGRADE_TABLE_SQ_LINK_ADD_COLUMN_UPDATE_USER, conn);
+      runQuery(QUERY_UPGRADE_TABLE_SQ_CONNECTION_ADD_COLUMN_CREATION_USER, conn);
+      runQuery(QUERY_UPGRADE_TABLE_SQ_CONNECTION_ADD_COLUMN_UPDATE_USER, conn);
       runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_CREATION_USER, conn);
       runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_UPDATE_USER, conn);
       runQuery(QUERY_UPGRADE_TABLE_SQ_SUBMISSION_ADD_COLUMN_CREATION_USER, conn);
       runQuery(QUERY_UPGRADE_TABLE_SQ_SUBMISSION_ADD_COLUMN_UPDATE_USER, conn);
     }
-    if(version <= 2) {
+    if(repositoryVersion <= 2) {
       runQuery(QUERY_UPGRADE_TABLE_SQ_SUBMISSION_MODIFY_COLUMN_SQS_EXTERNAL_ID_VARCHAR_50, conn);
       runQuery(QUERY_UPGRADE_TABLE_SQ_CONNECTOR_MODIFY_COLUMN_SQC_VERSION_VARCHAR_64, conn);
     }
-    if(version <= 3) {
+    if(repositoryVersion <= 3) {
       // Schema modifications
       runQuery(QUERY_CREATE_TABLE_SQ_DIRECTION, conn);
-      runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_RENAME_COLUMN_SQ_CFG_OPERATION_TO_SQ_CFG_DIRECTION, conn);
-      runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_RENAME_COLUMN_SQB_LINK_TO_SQB_FROM_LINK, conn);
-      runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_SQB_TO_LINK, conn);
-      runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_REMOVE_CONSTRAINT_SQB_SQ_LNK, conn);
-      runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQ_LNK_FROM, conn);
-      runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQ_LNK_TO, conn);
+      runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_RENAME_COLUMN_SQF_OPERATION_TO_SQF_DIRECTION, conn);
+      runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_RENAME_COLUMN_SQB_CONNECTION_TO_SQB_FROM_CONNECTION, conn);
+      runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_COLUMN_SQB_TO_CONNECTION, conn);
+      runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_REMOVE_CONSTRAINT_SQB_SQN, conn);
+      runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQN_FROM, conn);
+      runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_CONSTRAINT_SQB_SQN_TO, conn);
 
       // Data modifications only for non-fresh install.
-      if (version > 0) {
+      if (repositoryVersion > 0) {
         // Register HDFS connector
-        updteJobInternals(conn, registerHdfsConnector(conn));
+        updateJobRepositorySchemaAndData(conn, registerHdfsConnector(conn));
       }
 
-      // Change direction from VARCHAR to BIGINT + foreign key.
-      updateDirections(conn, insertDirections(conn));
-
       // Wait to remove SQB_TYPE (IMPORT/EXPORT) until we update data.
       // Data updates depend on knowledge of the type of job.
       runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_REMOVE_COLUMN_SQB_TYPE, conn);
 
-      // Add unique constraints on job and links.
+      // SQOOP-1498 rename entities
+      renameEntitiesForUpgrade(conn);
+      // Change direction from VARCHAR to BIGINT + foreign key.
+      updateDirections(conn, insertDirections(conn));
+    }
+    // Add unique constraints on job and links for version 4 onwards
+    if (repositoryVersion > 3) {
       runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_ADD_UNIQUE_CONSTRAINT_NAME, conn);
       runQuery(QUERY_UPGRADE_TABLE_SQ_LINK_ADD_UNIQUE_CONSTRAINT_NAME, conn);
     }
+    // last step upgrade the repository version to the latest value in the code
+    upgradeRepositoryVersion(conn);
+  }
 
-    ResultSet rs = null;
-    PreparedStatement stmt = null;
-    try {
-      stmt = conn.prepareStatement(STMT_DELETE_SYSTEM);
-      stmt.setString(1, DerbyRepoConstants.SYSKEY_VERSION);
-      stmt.executeUpdate();
+  // SQOOP-1498 refactoring related upgrades for table and column names
+  void renameEntitiesForUpgrade(Connection conn) {
+    // LINK
+    // drop the constraint before rename
+    runQuery(QUERY_UPGRADE_DROP_TABLE_SQ_CONNECTION_CONSTRAINT_1, conn);
+    runQuery(QUERY_UPGRADE_DROP_TABLE_SQ_CONNECTION_CONSTRAINT_2, conn);
+    runQuery(QUERY_UPGRADE_DROP_TABLE_SQ_CONNECTION_CONSTRAINT_3, conn);
+    runQuery(QUERY_UPGRADE_DROP_TABLE_SQ_CONNECTION_CONSTRAINT_4, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_CONNECTION_TO_SQ_LINK, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_CONNECTION_COLUMN_1, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_CONNECTION_COLUMN_2, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_CONNECTION_COLUMN_3, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_CONNECTION_COLUMN_4, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_CONNECTION_COLUMN_5, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_CONNECTION_COLUMN_6, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_CONNECTION_COLUMN_7, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_CONNECTION_COLUMN_8, conn);
 
-      closeStatements(stmt);
+    LOG.info("LINK TABLE altered");
+
+    // LINK_INPUT
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_CONNECTION_INPUT_TO_SQ_LINK_INPUT, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_CONNECTION_INPUT_COLUMN_1, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_CONNECTION_INPUT_COLUMN_2, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_CONNECTION_INPUT_COLUMN_3, conn);
+    runQuery(QUERY_UPGRADE_ADD_TABLE_SQ_LINK_INPUT_CONSTRAINT, conn);
+
+    LOG.info("LINK_INPUT TABLE altered");
+
+    // CONFIG
+    runQuery(QUERY_UPGRADE_DROP_TABLE_SQ_FORM_CONSTRAINT, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_FORM_TO_SQ_CONFIG, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_FORM_COLUMN_1, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_FORM_COLUMN_2, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_FORM_COLUMN_3, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_FORM_COLUMN_4, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_FORM_COLUMN_5, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_FORM_COLUMN_6, conn);
+
+    LOG.info("CONFIG TABLE altered");
+
+    // INPUT
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_INPUT_FORM_COLUMN, conn);
+    runQuery(QUERY_UPGRADE_ADD_TABLE_SQ_INPUT_CONSTRAINT, conn);
+
+    LOG.info("INPUT TABLE altered and constraints added");
+
+    // JOB
+
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_JOB_COLUMN_1, conn);
+    runQuery(QUERY_UPGRADE_RENAME_TABLE_SQ_JOB_COLUMN_2, conn);
+    runQuery(QUERY_UPGRADE_ADD_TABLE_SQ_JOB_CONSTRAINT_FROM, conn);
+    runQuery(QUERY_UPGRADE_ADD_TABLE_SQ_JOB_CONSTRAINT_TO, conn);
+
+    LOG.info("JOB TABLE altered and constraints added");
 
-      stmt = conn.prepareStatement(STMT_INSERT_SYSTEM);
-      stmt.setString(1, DerbyRepoConstants.SYSKEY_VERSION);
-      stmt.setString(2, "" + DerbyRepoConstants.VERSION);
-      stmt.executeUpdate();
-    } catch (SQLException e) {
-      LOG.error("Can't persist the repository version", e);
-    } finally {
-      closeResultSets(rs);
-      closeStatements(stmt);
-    }
+  }
+
+  private void upgradeRepositoryVersion(Connection conn) {
+    // remove the deprecated sys version
+    runQuery(STMT_DELETE_SYSTEM, conn, DerbyRepoConstants.SYSKEY_VERSION);
+    runQuery(STMT_DELETE_SYSTEM, conn, DerbyRepoConstants.SYSKEY_DERBY_REPOSITORY_VERSION);
+    runQuery(STMT_INSERT_SYSTEM, conn, DerbyRepoConstants.SYSKEY_DERBY_REPOSITORY_VERSION, ""
+        + DerbyRepoConstants.LATEST_DERBY_REPOSITORY_VERSION);
   }
 
   /**
@@ -626,52 +678,54 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
    *     Also update the relevant inputs as well.
    * @param conn
    */
-  private void updteJobInternals(Connection conn, long connectorId) {
+  // NOTE: This upgrade code happened before the SQOOP-1498 renaming, hence it uses the form/connection
+  // tables instead of the latest config/link tables
+  private void updateJobRepositorySchemaAndData(Connection conn, long connectorId) {
     if (LOG.isTraceEnabled()) {
       LOG.trace("Updating existing data for generic connectors.");
     }
 
-    runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_SQ_CFG_OPERATION_TO_SQ_CFG_DIRECTION, conn,
+    runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_SQF_OPERATION_TO_SQF_DIRECTION, conn,
         Direction.FROM.toString(), "IMPORT");
-    runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_SQ_CFG_OPERATION_TO_SQ_CFG_DIRECTION, conn,
+    runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_SQF_OPERATION_TO_SQF_DIRECTION, conn,
         Direction.TO.toString(), "EXPORT");
 
-    runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_CONNECTOR_HDFS_CONFIG_DIRECTION, conn,
+    runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_CONNECTOR_HDFS_FORM_DIRECTION, conn,
         Direction.FROM.toString(),
         "input");
-    runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_CONNECTOR_HDFS_CONFIG_DIRECTION, conn,
+    runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_CONNECTOR_HDFS_FORM_DIRECTION, conn,
         Direction.TO.toString(),
         "output");
 
-    runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_CONNECTOR, conn,
+    runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_CONNECTOR, conn,
         new Long(connectorId), "input", "output");
 
-    runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_INPUT_UPDATE_THROTTLING_CONFIG_INPUTS, conn,
+    runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_INPUT_UPDATE_THROTTLING_FORM_INPUTS, conn,
         "IMPORT", "EXPORT");
-    runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_REMOVE_EXTRA_CONFIG_INPUTS, conn,
+    runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_REMOVE_EXTRA_FORM_INPUTS, conn,
         "throttling", "EXPORT");
-    runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_REMOVE_EXTRA_DRIVER_CONFIG, conn,
+    runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_REMOVE_EXTRA_DRIVER_FORM, conn,
         "throttling", "EXPORT");
-    runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_DIRECTION_TO_NULL, conn,
+    runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_DIRECTION_TO_NULL, conn,
         "throttling");
-    runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_DRIVER_INDEX, conn,
+    runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_DRIVER_INDEX, conn,
         new Long(0), "throttling");
 
-    Long linkId = createHdfsLink(conn, connectorId);
-    runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_TO_LINK_COPY_SQB_FROM_LINK, conn,
+    Long linkId = createHdfsConnection(conn, connectorId);
+    runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_TO_CONNECTION_COPY_SQB_FROM_CONNECTION, conn,
         "EXPORT");
-    runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_FROM_LINK, conn,
+    runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_FROM_CONNECTION, conn,
         new Long(linkId), "EXPORT");
-    runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_TO_LINK, conn,
+    runQuery(QUERY_UPGRADE_TABLE_SQ_JOB_UPDATE_SQB_TO_CONNECTION, conn,
         new Long(linkId), "IMPORT");
 
-    runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_SQ_CFG_NAME, conn,
+    runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_SQF_NAME, conn,
         "fromJobConfig", "table", Direction.FROM.toString());
-    runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_TABLE_INPUT_NAMES, conn,
+    runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_TABLE_INPUT_NAMES, conn,
         Direction.FROM.toString().toLowerCase(), "fromJobConfig", Direction.FROM.toString());
-    runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_SQ_CFG_NAME, conn,
+    runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_SQF_NAME, conn,
         "toJobConfig", "table", Direction.TO.toString());
-    runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_UPDATE_TABLE_INPUT_NAMES, conn,
+    runQuery(QUERY_UPGRADE_TABLE_SQ_FORM_UPDATE_TABLE_INPUT_NAMES, conn,
         Direction.TO.toString().toLowerCase(), "toJobConfig", Direction.TO.toString());
 
     if (LOG.isTraceEnabled()) {
@@ -681,6 +735,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
 
   /**
    * Pre-register HDFS Connector so that config upgrade will work.
+   * NOTE: This should be used only in the upgrade path
    */
   protected long registerHdfsConnector(Connection conn) {
     if (LOG.isTraceEnabled()) {
@@ -730,13 +785,14 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
   }
 
   /**
-   * Create an HDFS link.
-   * Intended to be used when moving HDFS connector out of driverConfig
+   * Create an HDFS connection ( used only in version 2).
+   * Intended to be used when moving HDFS connector out of the sqoop driver
    * to its own connector.
    *
-   * NOTE: Upgrade path only!
+   * NOTE: Should be used only in the upgrade path!
    */
-  private Long createHdfsLink(Connection conn, Long connectorId) {
+  @Deprecated
+  private Long createHdfsConnection(Connection conn, Long connectorId) {
     if (LOG.isTraceEnabled()) {
       LOG.trace("Creating HDFS link.");
     }
@@ -744,9 +800,9 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
     PreparedStatement stmt = null;
     int result;
     try {
-      stmt = conn.prepareStatement(STMT_INSERT_LINK,
+      stmt = conn.prepareStatement(STMT_INSERT_CONNECTION,
           Statement.RETURN_GENERATED_KEYS);
-      stmt.setString(1, LINK_HDFS);
+      stmt.setString(1, CONNECTOR_HDFS);
       stmt.setLong(2, connectorId);
       stmt.setBoolean(3, true);
       stmt.setNull(4, Types.VARCHAR);
@@ -759,7 +815,6 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
         throw new SqoopException(DerbyRepoError.DERBYREPO_0012,
             Integer.toString(result));
       }
-
       ResultSet rsetConnectionId = stmt.getGeneratedKeys();
 
       if (!rsetConnectionId.next()) {
@@ -767,7 +822,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
       }
 
       if (LOG.isTraceEnabled()) {
-        LOG.trace("Created HDFS link.");
+        LOG.trace("Created HDFS connection.");
       }
 
       return rsetConnectionId.getLong(1);
@@ -782,15 +837,11 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
    * {@inheritDoc}
    */
   @Override
-  public boolean haveSuitableInternals(Connection conn) {
-    int version = detectVersion(conn);
-
-    if(version != DerbyRepoConstants.VERSION) {
-      return false;
-    }
-
+  public boolean isRespositorySuitableForUse(Connection conn) {
     // TODO(jarcec): Verify that all structures are present (e.g. something like corruption validation)
-    return true;
+    // NOTE: At this point is is just checking if the repo version matches the version
+    // in the upgraded code
+    return detectRepositoryVersion(conn) == DerbyRepoConstants.LATEST_DERBY_REPOSITORY_VERSION;
   }
 
   /**
@@ -807,7 +858,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
       baseConnectorFetchStmt = conn.prepareStatement(STMT_FETCH_BASE_CONNECTOR);
       baseConnectorFetchStmt.setString(1, shortName);
 
-      List<MConnector> connectors = loadConnectors(baseConnectorFetchStmt,conn);
+      List<MConnector> connectors = loadConnectors(baseConnectorFetchStmt, conn);
 
       if (connectors.size()==0) {
         LOG.debug("No connector found by name: " + shortName);
@@ -828,7 +879,6 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
     }
   }
 
-
   /**
    * {@inheritDoc}
    */
@@ -980,7 +1030,6 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
       closeStatements(stmt);
     }
   }
-
   /**
    * {@inheritDoc}
    */
@@ -1195,7 +1244,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
    * {@inheritDoc}
    */
   @Override
-  public void updateConnector(MConnector mConnector, Connection conn) {
+  public void upgradeConnector(MConnector mConnector, Connection conn) {
     PreparedStatement updateConnectorStatement = null;
     PreparedStatement deleteConfig = null;
     PreparedStatement deleteInput = null;
@@ -1230,7 +1279,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
    * {@inheritDoc}
    */
   @Override
-  public void updateDriver(MDriver mDriver, Connection conn) {
+  public void upgradeDriver(MDriver mDriver, Connection conn) {
     PreparedStatement deleteConfig = null;
     PreparedStatement deleteInput = null;
     try {
@@ -2299,7 +2348,7 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
       baseInputStmt.setBoolean(5, input.isSensitive());
       // String specific column(s)
       if (input.getType().equals(MInputType.STRING)) {
-        MStringInput	strInput = (MStringInput) input;
+        MStringInput  strInput = (MStringInput) input;
         baseInputStmt.setShort(6, strInput.getMaxLength());
       } else {
         baseInputStmt.setNull(6, Types.INTEGER);
@@ -2741,4 +2790,4 @@ public class DerbyRepositoryHandler extends JdbcRepositoryHandler {
       LOG.error("\t" + object.getClass().getSimpleName() + ": " + object.toString());
     }
   }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/6ae93e6a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java
----------------------------------------------------------------------
diff --git a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java
index cf6e657..59773e1 100644
--- a/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java
+++ b/repository/repository-derby/src/main/java/org/apache/sqoop/repository/derby/DerbySchemaConstants.java
@@ -29,11 +29,9 @@ public final class DerbySchemaConstants {
   private static final String CONSTRAINT_PREFIX = "FK_";
 
   // SQ_SYSTEM
-
   public static final String TABLE_SQ_SYSTEM_NAME = "SQ_SYSTEM";
 
-  public static final String TABLE_SQ_SYSTEM = SCHEMA_PREFIX
-    + TABLE_SQ_SYSTEM_NAME;
+  public static final String TABLE_SQ_SYSTEM = SCHEMA_PREFIX + TABLE_SQ_SYSTEM_NAME;
 
   public static final String COLUMN_SQM_ID = "SQM_ID";
 
@@ -42,22 +40,18 @@ public final class DerbySchemaConstants {
   public static final String COLUMN_SQM_VALUE = "SQM_VALUE";
 
   // SQ_DIRECTION
-
   public static final String TABLE_SQ_DIRECTION_NAME = "SQ_DIRECTION";
 
-  public static final String TABLE_SQ_DIRECTION = SCHEMA_PREFIX
-      + TABLE_SQ_DIRECTION_NAME;
+  public static final String TABLE_SQ_DIRECTION = SCHEMA_PREFIX + TABLE_SQ_DIRECTION_NAME;
 
   public static final String COLUMN_SQD_ID = "SQD_ID";
 
   public static final String COLUMN_SQD_NAME = "SQD_NAME";
 
   // SQ_CONNECTOR
-
   public static final String TABLE_SQ_CONNECTOR_NAME = "SQ_CONNECTOR";
 
-  public static final String TABLE_SQ_CONNECTOR = SCHEMA_PREFIX
-    + TABLE_SQ_CONNECTOR_NAME;
+  public static final String TABLE_SQ_CONNECTOR = SCHEMA_PREFIX + TABLE_SQ_CONNECTOR_NAME;
 
   public static final String COLUMN_SQC_ID = "SQC_ID";
 
@@ -82,33 +76,55 @@ public final class DerbySchemaConstants {
 
   public static final String CONSTRAINT_SQCD_SQC_NAME = CONSTRAINT_PREFIX + "SQCD_SQC";
 
+ // FK to the SQ_CONNECTOR table
   public static final String CONSTRAINT_SQCD_SQC = SCHEMA_PREFIX + CONSTRAINT_SQCD_SQC_NAME;
 
   public static final String CONSTRAINT_SQCD_SQD_NAME = CONSTRAINT_PREFIX + "SQCD_SQD";
 
+  // FK to the SQ_DIRECTION able
   public static final String CONSTRAINT_SQCD_SQD = SCHEMA_PREFIX + CONSTRAINT_SQCD_SQD_NAME;
 
   // SQ_CONFIG
-
+  @Deprecated // used only for upgrade
+  public static final String TABLE_SQ_FORM_NAME = "SQ_FORM";
   public static final String TABLE_SQ_CONFIG_NAME = "SQ_CONFIG";
 
-  public static final String TABLE_SQ_CONFIG = SCHEMA_PREFIX
-    + TABLE_SQ_CONFIG_NAME;
+  @Deprecated // used only for upgrade
+  public static final String TABLE_SQ_FORM = SCHEMA_PREFIX + TABLE_SQ_FORM_NAME;
+  public static final String TABLE_SQ_CONFIG = SCHEMA_PREFIX + TABLE_SQ_CONFIG_NAME;
 
+  @Deprecated // used only for upgrade
+  public static final String COLUMN_SQF_ID = "SQF_ID";
   public static final String COLUMN_SQ_CFG_ID = "SQ_CFG_ID";
 
-  public static final String COLUMN_SQ_CFG_OWNER = "SQ_CFG_OWNER";
+  @Deprecated // used only for upgrade
+  public static final String COLUMN_SQF_CONNECTOR = "SQF_CONNECTOR";
+  public static final String COLUMN_SQ_CFG_CONNECTOR = "SQ_CFG_CONNECTOR";
 
-  public static final String COLUMN_SQ_CFG_OPERATION = "SQ_CFG_OPERATION";
+  @Deprecated // used only for upgrade
+  public static final String COLUMN_SQF_OPERATION = "SQF_OPERATION";
 
+  @Deprecated // used only for upgrade
+  public static final String COLUMN_SQF_DIRECTION = "SQF_DIRECTION";
   public static final String COLUMN_SQ_CFG_DIRECTION = "SQ_CFG_DIRECTION";
 
+  @Deprecated // used only for upgrade
+  public static final String COLUMN_SQF_NAME = "SQF_NAME";
   public static final String COLUMN_SQ_CFG_NAME = "SQ_CFG_NAME";
 
+  @Deprecated // used only for upgrade
+  public static final String COLUMN_SQF_TYPE = "SQF_TYPE";
   public static final String COLUMN_SQ_CFG_TYPE = "SQ_CFG_TYPE";
 
+  @Deprecated // used only for upgrade
+  public static final String COLUMN_SQF_INDEX = "SQF_INDEX";
   public static final String COLUMN_SQ_CFG_INDEX = "SQ_CFG_INDEX";
 
+  @Deprecated // used only for upgrade
+  public static final String CONSTRAINT_SQF_SQC_NAME = CONSTRAINT_PREFIX + "SQF_SQC";
+  @Deprecated // used only for upgrade
+  public static final String CONSTRAINT_SQF_SQC = SCHEMA_PREFIX + CONSTRAINT_SQF_SQC_NAME;
+
   public static final String CONSTRAINT_SQ_CFG_SQC_NAME = CONSTRAINT_PREFIX + "SQ_CFG_SQC";
 
   public static final String CONSTRAINT_SQ_CFG_SQC = SCHEMA_PREFIX + CONSTRAINT_SQ_CFG_SQC_NAME;
@@ -122,29 +138,34 @@ public final class DerbySchemaConstants {
 
   public static final String COLUMN_SQ_CFG_DIR_ID = "SQ_CFG_DIR_ID";
 
+  @Deprecated // used only for the upgrade code
+  public static final String COLUMN_SQ_CFG_DIR_FORM = "SQ_CFG_DIR_FORM";
   public static final String COLUMN_SQ_CFG_DIR_CONFIG = "SQ_CFG_DIR_CONFIG";
 
   public static final String COLUMN_SQ_CFG_DIR_DIRECTION = "SQ_CFG_DIR_DIRECTION";
 
   public static final String CONSTRAINT_SQ_CFG_DIR_CONFIG_NAME = CONSTRAINT_PREFIX + "SQ_CFG_DIR_CONFIG";
 
+  // this is a FK to the SQ_CONFIG table
   public static final String CONSTRAINT_SQ_CFG_DIR_CONFIG = SCHEMA_PREFIX + CONSTRAINT_SQ_CFG_DIR_CONFIG_NAME;
 
   public static final String CONSTRAINT_SQ_CFG_DIR_DIRECTION_NAME = CONSTRAINT_PREFIX + "SQ_CFG_DIR_DIRECTION";
 
+  // this a FK to the SQ_DIRECTION table
   public static final String CONSTRAINT_SQ_CFG_DIR_DIRECTION = SCHEMA_PREFIX + CONSTRAINT_SQ_CFG_DIR_DIRECTION_NAME;
 
   // SQ_INPUT
 
   public static final String TABLE_SQ_INPUT_NAME = "SQ_INPUT";
 
-  public static final String TABLE_SQ_INPUT = SCHEMA_PREFIX
-    + TABLE_SQ_INPUT_NAME;
+  public static final String TABLE_SQ_INPUT = SCHEMA_PREFIX + TABLE_SQ_INPUT_NAME;
 
   public static final String COLUMN_SQI_ID = "SQI_ID";
 
   public static final String COLUMN_SQI_NAME = "SQI_NAME";
 
+  @Deprecated // used only for upgrade
+  public static final String COLUMN_SQI_FORM = "SQI_FORM";
   public static final String COLUMN_SQI_CONFIG = "SQI_CONFIG";
 
   public static final String COLUMN_SQI_INDEX = "SQI_INDEX";
@@ -157,33 +178,53 @@ public final class DerbySchemaConstants {
 
   public static final String COLUMN_SQI_ENUMVALS = "SQI_ENUMVALS";
 
-  public static final String CONSTRAINT_SQI_SQ_CFG_NAME = CONSTRAINT_PREFIX + "SQI_SQ_CFG";
+  @Deprecated // used only for upgrade
+  public static final String CONSTRAINT_SQI_SQF_NAME = CONSTRAINT_PREFIX + "SQI_SQF";
+  @Deprecated // used only for upgrade
+  public static final String CONSTRAINT_SQI_SQF = SCHEMA_PREFIX + CONSTRAINT_SQI_SQF_NAME;
 
+  public static final String CONSTRAINT_SQI_SQ_CFG_NAME = CONSTRAINT_PREFIX + "SQI_SQ_CFG";
   public static final String CONSTRAINT_SQI_SQ_CFG = SCHEMA_PREFIX + CONSTRAINT_SQI_SQ_CFG_NAME;
 
+  @Deprecated // used only for upgrade
+  public static final String TABLE_SQ_CONNECTION_NAME = "SQ_CONNECTION";
   public static final String TABLE_SQ_LINK_NAME = "SQ_LINK";
 
-  public static final String TABLE_SQ_LINK = SCHEMA_PREFIX
-      + TABLE_SQ_LINK_NAME;
+  @Deprecated // used only for upgrade
+  public static final String TABLE_SQ_CONNECTION = SCHEMA_PREFIX + TABLE_SQ_CONNECTION_NAME;
+  public static final String TABLE_SQ_LINK = SCHEMA_PREFIX + TABLE_SQ_LINK_NAME;
 
+  @Deprecated // used only for upgrade
+  public static final String COLUMN_SQN_ID = "SQN_ID";
   public static final String COLUMN_SQ_LNK_ID = "SQ_LNK_ID";
-
+  @Deprecated // used only for upgrade
+  public static final String COLUMN_SQN_NAME = "SQN_NAME";
   public static final String COLUMN_SQ_LNK_NAME = "SQ_LNK_NAME";
-
+  @Deprecated // used only for upgrade
+  public static final String COLUMN_SQN_CONNECTOR = "SQN_CONNECTOR";
   public static final String COLUMN_SQ_LNK_CONNECTOR = "SQ_LNK_CONNECTOR";
-
+  @Deprecated // used only for upgrade
+  public static final String COLUMN_SQN_CREATION_USER = "SQN_CREATION_USER";
   public static final String COLUMN_SQ_LNK_CREATION_USER = "SQ_LNK_CREATION_USER";
-
+  @Deprecated // used only for upgrade
+  public static final String COLUMN_SQN_CREATION_DATE = "SQN_CREATION_DATE";
   public static final String COLUMN_SQ_LNK_CREATION_DATE = "SQ_LNK_CREATION_DATE";
-
+  @Deprecated // used only for upgrade
+  public static final String COLUMN_SQN_UPDATE_USER = "SQN_UPDATE_USER";
   public static final String COLUMN_SQ_LNK_UPDATE_USER = "SQ_LNK_UPDATE_USER";
-
+  @Deprecated // used only for upgrade
+  public static final String COLUMN_SQN_UPDATE_DATE = "SQN_UPDATE_DATE";
   public static final String COLUMN_SQ_LNK_UPDATE_DATE = "SQ_LNK_UPDATE_DATE";
-
+  @Deprecated // used only for upgrade
+  public static final String COLUMN_SQN_ENABLED = "SQN_ENABLED";
   public static final String COLUMN_SQ_LNK_ENABLED = "SQ_LNK_ENABLED";
 
+  @Deprecated
+  public static final String CONSTRAINT_SQN_SQC_NAME = CONSTRAINT_PREFIX + "SQN_SQC";
   public static final String CONSTRAINT_SQ_LNK_SQC_NAME = CONSTRAINT_PREFIX + "SQ_LNK_SQC";
 
+  @Deprecated
+  public static final String CONSTRAINT_SQN_SQC = SCHEMA_PREFIX + CONSTRAINT_SQN_SQC_NAME;
   public static final String CONSTRAINT_SQ_LNK_SQC = SCHEMA_PREFIX + CONSTRAINT_SQ_LNK_SQC_NAME;
 
   public static final String CONSTRAINT_SQ_LNK_NAME_UNIQUE_NAME = CONSTRAINT_PREFIX + "SQ_LNK_NAME_UNIQUE";
@@ -194,20 +235,25 @@ public final class DerbySchemaConstants {
 
   public static final String TABLE_SQ_JOB_NAME = "SQ_JOB";
 
-  public static final String TABLE_SQ_JOB = SCHEMA_PREFIX
-    + TABLE_SQ_JOB_NAME;
+  public static final String TABLE_SQ_JOB = SCHEMA_PREFIX + TABLE_SQ_JOB_NAME;
 
   public static final String COLUMN_SQB_ID = "SQB_ID";
 
   public static final String COLUMN_SQB_NAME = "SQB_NAME";
 
+  @Deprecated
+  public static final String COLUMN_SQB_CONNECTION = "SQB_CONNECTION";
   public static final String COLUMN_SQB_LINK = "SQB_LINK";
 
   public static final String COLUMN_SQB_TYPE = "SQB_TYPE";
 
+  @Deprecated // used only for upgrade since the table CONNECTION changed to LINK
+  public static final String COLUMN_SQB_FROM_CONNECTION = "SQB_FROM_CONNECTION";
   public static final String COLUMN_SQB_FROM_LINK = "SQB_FROM_LINK";
 
-  public static final String COLUMN_SQB_TO_LINK = "SQB_TO_LINK";
+  @Deprecated  // used only for upgrade since the table CONNECTION changed to LINK
+ public static final String COLUMN_SQB_TO_CONNECTION = "SQB_TO_CONNECTION";
+ public static final String COLUMN_SQB_TO_LINK = "SQB_TO_LINK";
 
   public static final String COLUMN_SQB_CREATION_USER = "SQB_CREATION_USER";
 
@@ -219,6 +265,19 @@ public final class DerbySchemaConstants {
 
   public static final String COLUMN_SQB_ENABLED = "SQB_ENABLED";
 
+  @Deprecated // used only for upgrade
+  public static final String CONSTRAINT_SQB_SQN_NAME = CONSTRAINT_PREFIX + "SQB_SQN";
+  @Deprecated // used only for upgrade
+  public static final String CONSTRAINT_SQB_SQN = SCHEMA_PREFIX + CONSTRAINT_SQB_SQN_NAME;
+  @Deprecated // used only for upgrade
+  public static final String CONSTRAINT_SQB_SQN_FROM_NAME = CONSTRAINT_PREFIX + "SQB_SQN_FROM";
+  @Deprecated // used only for upgrade
+  public static final String CONSTRAINT_SQB_SQN_FROM = SCHEMA_PREFIX + CONSTRAINT_SQB_SQN_FROM_NAME;
+  @Deprecated // used only for upgrade
+  public static final String CONSTRAINT_SQB_SQN_TO_NAME = CONSTRAINT_PREFIX + "SQB_SQN_TO";
+  @Deprecated // used only for upgrade
+  public static final String CONSTRAINT_SQB_SQN_TO = SCHEMA_PREFIX + CONSTRAINT_SQB_SQN_TO_NAME;
+
   public static final String CONSTRAINT_SQB_SQ_LNK_NAME = CONSTRAINT_PREFIX + "SQB_SQ_LNK";
 
   public static final String CONSTRAINT_SQB_SQ_LNK = SCHEMA_PREFIX + CONSTRAINT_SQB_SQ_LNK_NAME;
@@ -235,35 +294,47 @@ public final class DerbySchemaConstants {
 
   public static final String CONSTRAINT_SQB_NAME_UNIQUE = SCHEMA_PREFIX + CONSTRAINT_SQB_NAME_UNIQUE_NAME;
 
-  // SQ_CONNECTION_INPUT
+  // SQ_LINK_INPUT
+  @Deprecated // only used for upgrade
+  public static final String TABLE_SQ_CONNECTION_INPUT_NAME = "SQ_CONNECTION_INPUT";
+  public static final String TABLE_SQ_LINK_INPUT_NAME = "SQ_LINK_INPUT";
 
-  public static final String TABLE_SQ_LINK_INPUT_NAME =
-    "SQ_LINK_INPUT";
-
-  public static final String TABLE_SQ_LINK_INPUT = SCHEMA_PREFIX
-    + TABLE_SQ_LINK_INPUT_NAME;
+  @Deprecated // only used for upgrade
+  public static final String TABLE_SQ_CONNECTION_INPUT = SCHEMA_PREFIX + TABLE_SQ_CONNECTION_INPUT_NAME;
+  public static final String TABLE_SQ_LINK_INPUT = SCHEMA_PREFIX + TABLE_SQ_LINK_INPUT_NAME;
 
+  @Deprecated // only used for upgrade
+  public static final String COLUMN_SQNI_CONNECTION = "SQNI_CONNECTION";
   public static final String COLUMN_SQ_LNKI_LINK = "SQ_LNKI_LINK";
 
+  @Deprecated // only used for upgrade
+  public static final String COLUMN_SQNI_INPUT = "SQNI_INPUT";
   public static final String COLUMN_SQ_LNKI_INPUT = "SQ_LNKI_INPUT";
 
+  @Deprecated // only used for upgrade
+  public static final String COLUMN_SQNI_VALUE = "SQNI_VALUE";
   public static final String COLUMN_SQ_LNKI_VALUE = "SQ_LNKI_VALUE";
 
+  @Deprecated // only used for upgrade
+  public static final String CONSTRAINT_SQNI_SQN_NAME = CONSTRAINT_PREFIX + "SQNI_SQN";
   public static final String CONSTRAINT_SQ_LNKI_SQ_LNK_NAME = CONSTRAINT_PREFIX + "SQ_LNKI_SQ_LNK";
 
+  @Deprecated // only used for upgrade
+  public static final String CONSTRAINT_SQNI_SQN = SCHEMA_PREFIX + CONSTRAINT_SQNI_SQN_NAME;
   public static final String CONSTRAINT_SQ_LNKI_SQ_LNK = SCHEMA_PREFIX + CONSTRAINT_SQ_LNKI_SQ_LNK_NAME;
 
+  @Deprecated // only used for upgrade
+  public static final String CONSTRAINT_SQNI_SQI_NAME = CONSTRAINT_PREFIX + "SQNI_SQI";
   public static final String CONSTRAINT_SQ_LNKI_SQI_NAME = CONSTRAINT_PREFIX + "SQ_LNKI_SQI";
-
+  @Deprecated // only used for upgrade
+  public static final String CONSTRAINT_SQNI_SQI = SCHEMA_PREFIX + CONSTRAINT_SQNI_SQI_NAME;
   public static final String CONSTRAINT_SQ_LNKI_SQI = SCHEMA_PREFIX + CONSTRAINT_SQ_LNKI_SQI_NAME;
 
   // SQ_JOB_INPUT
 
-  public static final String TABLE_SQ_JOB_INPUT_NAME =
-    "SQ_JOB_INPUT";
+  public static final String TABLE_SQ_JOB_INPUT_NAME = "SQ_JOB_INPUT";
 
-  public static final String TABLE_SQ_JOB_INPUT = SCHEMA_PREFIX
-      + TABLE_SQ_JOB_INPUT_NAME;
+  public static final String TABLE_SQ_JOB_INPUT = SCHEMA_PREFIX + TABLE_SQ_JOB_INPUT_NAME;
 
   public static final String COLUMN_SQBI_JOB = "SQBI_JOB";
 
@@ -281,11 +352,9 @@ public final class DerbySchemaConstants {
 
   // SQ_SUBMISSION
 
-  public static final String TABLE_SQ_SUBMISSION_NAME =
-    "SQ_SUBMISSION";
+  public static final String TABLE_SQ_SUBMISSION_NAME = "SQ_SUBMISSION";
 
-  public static final String TABLE_SQ_SUBMISSION = SCHEMA_PREFIX
-    + TABLE_SQ_SUBMISSION_NAME;
+  public static final String TABLE_SQ_SUBMISSION = SCHEMA_PREFIX + TABLE_SQ_SUBMISSION_NAME;
 
   public static final String COLUMN_SQS_ID = "SQS_ID";
 
@@ -315,11 +384,9 @@ public final class DerbySchemaConstants {
 
   // SQ_COUNTER_GROUP
 
-  public static final String TABLE_SQ_COUNTER_GROUP_NAME =
-    "SQ_COUNTER_GROUP";
+  public static final String TABLE_SQ_COUNTER_GROUP_NAME = "SQ_COUNTER_GROUP";
 
-  public static final String TABLE_SQ_COUNTER_GROUP = SCHEMA_PREFIX
-      + TABLE_SQ_COUNTER_GROUP_NAME;
+  public static final String TABLE_SQ_COUNTER_GROUP = SCHEMA_PREFIX + TABLE_SQ_COUNTER_GROUP_NAME;
 
   public static final String COLUMN_SQG_ID = "SQG_ID";
 
@@ -327,11 +394,9 @@ public final class DerbySchemaConstants {
 
   // SQ_COUNTER_GROUP
 
-  public static final String TABLE_SQ_COUNTER_NAME =
-    "SQ_COUNTER";
+  public static final String TABLE_SQ_COUNTER_NAME = "SQ_COUNTER";
 
-  public static final String TABLE_SQ_COUNTER = SCHEMA_PREFIX
-      + TABLE_SQ_COUNTER_NAME;
+  public static final String TABLE_SQ_COUNTER = SCHEMA_PREFIX + TABLE_SQ_COUNTER_NAME;
 
   public static final String COLUMN_SQR_ID = "SQR_ID";
 
@@ -339,11 +404,10 @@ public final class DerbySchemaConstants {
 
   // SQ_COUNTER_SUBMISSION
 
-  public static final String TABLE_SQ_COUNTER_SUBMISSION_NAME =
-    "SQ_COUNTER_SUBMISSION";
+  public static final String TABLE_SQ_COUNTER_SUBMISSION_NAME = "SQ_COUNTER_SUBMISSION";
 
   public static final String TABLE_SQ_COUNTER_SUBMISSION = SCHEMA_PREFIX
-    + TABLE_SQ_COUNTER_SUBMISSION_NAME;
+      + TABLE_SQ_COUNTER_SUBMISSION_NAME;
 
   public static final String COLUMN_SQRS_GROUP = "SQRS_GROUP";
 
@@ -388,4 +452,4 @@ public final class DerbySchemaConstants {
   private DerbySchemaConstants() {
     // Disable explicit object creation
   }
-}
+}
\ No newline at end of file