public function execute($taskName) { $dsId = $this->getCurrentDataSourceId(); $this->logger->info("Loading schema objects..."); $finder = new SchemaFinder(); $finder->paths = $this->config->getSchemaPaths() ?: array(); $finder->find(); $schemas = $finder->getSchemas(); $this->logger->info('Found ' . count($schemas) == 0 . ' schemas'); $generator = new MigrationGenerator(Console::getInstance()->getLogger(), 'db/migrations'); $this->logger->info("Creating migration script from diff"); list($class, $path) = $generator->generateWithDiff($taskName, $dsId, $schemas); $this->logger->info("Migration script is generated: {$path}"); }
/** * Returns schema objects * * @return array schema objects */ public static function findSchemasByArguments(ConfigLoader $loader, $args, $logger = null) { if (count($args) && !file_exists($args[0])) { $classes = array(); // it's classnames foreach ($args as $class) { // call class loader to load if (class_exists($class, true)) { $classes[] = $class; } else { if ($logger) { $logger->warn("{$class} not found."); } else { echo ">>> {$class} not found.\n"; } } } return ClassUtils::schema_classes_to_objects($classes); } else { $finder = new SchemaFinder(); if (count($args) && file_exists($args[0])) { $finder->paths = $args; foreach ($args as $file) { if (is_file($file)) { require_once $file; } } } elseif ($paths = $loader->getSchemaPaths()) { $finder->paths = $paths; } $finder->find(); // load class from class map if ($classMap = $loader->getClassMap()) { foreach ($classMap as $file => $class) { if (!is_integer($file) && is_string($file)) { require $file; } } } return $finder->getSchemas(); } }