/** * @return MetaConfiguration **/ public function buildSchema() { $out = $this->getOutput(); $out->newLine()->infoLine('Building DB schema:'); $schema = SchemaBuilder::getHead(); $tables = array(); foreach ($this->classes as $class) { if (!$class->getParent() && !count($class->getProperties()) || !$class->getPattern()->tableExists()) { continue; } foreach ($class->getAllProperties() as $property) { $tables[$class->getTableName()][$property->getColumnName()] = $property; } } foreach ($tables as $name => $propertyList) { if ($propertyList) { $schema .= SchemaBuilder::buildTable($name, $propertyList); } } foreach ($this->classes as $class) { if (!$class->getPattern()->tableExists()) { continue; } $schema .= SchemaBuilder::buildRelations($class); } $schema .= '?>'; BasePattern::dumpFile(ONPHP_META_AUTO_DIR . 'schema.php', Format::indentize($schema)); return $this; }