/** * @return MetaConfiguration **/ public function buildSchemaChanges() { $out = $this->getOutput(); $out->newLine()->infoLine('Suggested DB-schema changes: '); require ONPHP_META_AUTO_DIR . 'schema.php'; foreach ($this->classes as $class) { if ($class->getTypeId() == MetaClassType::CLASS_ABSTRACT || $class->getPattern() instanceof EnumerationClassPattern) { continue; } try { $target = $schema->getTableByName($class->getTableName()); } catch (MissingElementException $e) { // dropped or tableless continue; } try { $db = DBPool::me()->getLink($class->getSourceLink()); } catch (BaseException $e) { $out->errorLine('Can not connect using source link in \'' . $class->getName() . '\' class, skipping this step.'); break; } try { $source = $db->getTableInfo($class->getTableName()); } catch (UnsupportedMethodException $e) { $out->errorLine(get_class($db) . ' does not support tables introspection yet.', true); break; } catch (ObjectNotFoundException $e) { $out->errorLine("table '{$class->getTableName()}' not found, skipping."); continue; } $diff = DBTable::findDifferences($db->getDialect(), $source, $target); if ($diff) { foreach ($diff as $line) { $out->warningLine($line); } $out->newLine(); } } return $this; }