/** * Compares tables * * @param Table $table * * @return array * @throws \Exception */ public function equals(Table $table) { $prefix = $this->getName() . ': '; $errors = []; if ($table->getName() !== $this->getName()) { throw new \Exception('Comparing Incomparable Tables'); } if ($table->getEngine() !== $this->getEngine()) { $errors[] = $prefix . 'Engine Does Not Match:' . "\n" . $table->getEngine() . "\n" . $this->getEngine(); } if ($table->getDefaultCharset() !== $this->getDefaultCharset()) { $errors[] = $prefix . 'Default Charset Does Not Match:' . "\n" . $table->getDefaultCharset() . "\n" . $this->getDefaultCharset(); } if ($table->getCollate() !== $this->getCollate()) { $errors[] = $prefix . 'Collate Does Not Match:' . "\n" . $table->getCollate() . "\n" . $this->getCollate(); } $errors = array_merge($errors, $this->equalsLines($table, $prefix)); $errors = array_merge($errors, $this->equalsKeys($table, $prefix)); $errors = array_merge($errors, $this->equalsConstraints($table, $prefix)); return $errors; }
/** * Builds a table * @param string[] $ignoreTables * @return void */ private function buildDatabase($ignoreTables) { $tables = $this->getDbAdapter()->query('SHOW FULL TABLES WHERE Table_Type!="VIEW"')->fetchAll(); array_walk($tables, function (&$item) { $item = $item[0]; }); $tables = array_diff($tables, $ignoreTables); $tableObjects = []; foreach ($tables as $table) { $tableObject = new Table($this->getDbAdapter(), $table); $tableObjects[$tableObject->getName()] = $tableObject; } $this->setTables($tableObjects); }