Exemple #1
0
 function getDiff()
 {
     $diffSequence = [];
     // Tables
     $tableData = new TableData($this->manager);
     $sourceTables = $this->manager->getTables('source');
     $targetTables = $this->manager->getTables('target');
     $commonTables = array_intersect($sourceTables, $targetTables);
     foreach ($commonTables as $table) {
         try {
             $diffs = $tableData->getDiff($table);
             $diffSequence = array_merge($diffSequence, $diffs);
         } catch (DataException $e) {
             Logger::error($e->getMessage());
         }
     }
     $addedTables = array_diff($sourceTables, $targetTables);
     foreach ($addedTables as $table) {
         $diffs = $tableData->getNewData($table);
         $diffSequence = array_merge($diffSequence, $diffs);
     }
     $deletedTables = array_diff($targetTables, $sourceTables);
     foreach ($deletedTables as $table) {
         $diffs = $tableData->getOldData($table);
         $diffSequence = array_merge($diffSequence, $diffs);
     }
     return $diffSequence;
 }
 public function getDiff($params)
 {
     // Connect and test accessibility
     $this->manager->connect($params);
     $this->manager->testResources($params);
     // Schema diff
     $schemaDiff = [];
     if ($params->type !== 'data') {
         if ($params->input['kind'] === 'db') {
             $dbSchema = new DBSchema($this->manager);
             $schemaDiff = $dbSchema->getDiff();
         } else {
             $tableSchema = new TableSchema($this->manager);
             $schemaDiff = $tableSchema->getDiff($params->input['source']['table']);
         }
     }
     // Data diff
     $dataDiff = [];
     if ($params->type !== 'schema') {
         if ($params->input['kind'] === 'db') {
             $dbData = new DBData($this->manager);
             $dataDiff = $dbData->getDiff();
         } else {
             $tableData = new TableData($this->manager);
             $dataDiff = $tableData->getDiff($params->input['source']['table']);
         }
     }
     return ['schema' => $schemaDiff, 'data' => $dataDiff];
 }