system/src/sc/lang/sql/SQLFileModel.java
public SQLFileModel alterTo(SQLFileModel newModel, ArrayList<SchemaChangeDetail> notUpgradeable) {
      if (sqlCommands == null || sqlCommands.size() == 0)
         return newModel;

      SQLFileModel resModel = new SQLFileModel();
      resModel.srcType = newModel.srcType;

      if (newModel.sqlCommands != null) {
         for (SQLCommand newCmd:newModel.sqlCommands) {
            // If this exact SQL command was in the old model just skip it
            SQLCommand sameCmd = findSameCommand(newCmd);
            if (sameCmd != null)
               continue;
            // Some SQL commands have a name - table, sequence, index, function - so if they don't match we either alter or drop/create
            SQLCommand oldCmd = findMatchingCommand(newCmd);
            if (oldCmd == null) {
               resModel.addCommand((SQLCommand) newCmd.deepCopy(ISemanticNode.CopyNormal | ISemanticNode.CopyParseNode, null));
            }
            else {
               oldCmd.alterTo(resModel, newCmd, notUpgradeable);
            }
         }
      }

      for (SQLCommand oldCmd:sqlCommands) {
         SQLCommand matchingCmd = newModel.findMatchingCommand(oldCmd);
         if (matchingCmd == null) {
            resModel.addCommand(oldCmd.getDropCommand());
         }
      }
      return resModel;
   }
/**
    * This is the old SQL model that needs to be altered to convert a database schema to the one defined in the new toModel.
    * We'll return a new model with the differences
    */
This is the old SQL model that needs to be altered to convert a database schema to the one defined in the new toModel.
We'll return a new model with the differences
This is the old SQL model that needs to be altered to convert a database schema to the one defined in the new toModel . We ' ll return a new model with the differences
public SQLFileModel alterTo(SQLFileModel newModel, ArrayList<SchemaChangeDetail> notUpgradeable) {
      if (sqlCommands == null || sqlCommands.size() == 0)
         return newModel;
      SQLFileModel resModel = new SQLFileModel();
      resModel.srcType = newModel.srcType;
      if (newModel.sqlCommands != null) {
         for (SQLCommand newCmd:newModel.sqlCommands) {
            SQLCommand sameCmd = findSameCommand(newCmd);
            if (sameCmd != null)
               continue;
            SQLCommand oldCmd = findMatchingCommand(newCmd);
            if (oldCmd == null) {
               resModel.addCommand((SQLCommand) newCmd.deepCopy(ISemanticNode.CopyNormal | ISemanticNode.CopyParseNode, null));
            }
            else {
               oldCmd.alterTo(resModel, newCmd, notUpgradeable);
            }
         }
      }
      for (SQLCommand oldCmd:sqlCommands) {
         SQLCommand matchingCmd = newModel.findMatchingCommand(oldCmd);
         if (matchingCmd == null) {
            resModel.addCommand(oldCmd.getDropCommand());
         }
      }
      return resModel;
   }
public SQLFileModel alterTo ( SQLFileModel newModel , ArrayList < SchemaChangeDetail > notUpgradeable ) { if ( sqlCommands == null || sqlCommands . size ( ) == 0 ) return newModel ; SQLFileModel resModel = new SQLFileModel ( ) ; resModel . srcType = newModel . srcType ; if ( newModel . sqlCommands != null ) { for ( SQLCommand newCmd : newModel . sqlCommands ) { SQLCommand sameCmd = findSameCommand ( newCmd ) ; if ( sameCmd != null ) continue ; SQLCommand oldCmd = findMatchingCommand ( newCmd ) ; if ( oldCmd == null ) { resModel . addCommand ( ( SQLCommand ) newCmd . deepCopy ( ISemanticNode . CopyNormal | ISemanticNode . CopyParseNode , null ) ) ; } else { oldCmd . alterTo ( resModel , newCmd , notUpgradeable ) ; } } } for ( SQLCommand oldCmd : sqlCommands ) { SQLCommand matchingCmd = newModel . findMatchingCommand ( oldCmd ) ; if ( matchingCmd == null ) { resModel . addCommand ( oldCmd . getDropCommand ( ) ) ; } } return resModel ; }
This is the old SQL model that needs to be altered to convert a database schema to the one defined in the new toModel.
This is the old SQL model that needs to be altered to convert a database schema to the one defined in the new toModel .
// If this exact SQL command was in the old model just skip it // Some SQL commands have a name - table, sequence, index, function - so if they don't match we either alter or drop/create