Exemplo n.º 1
0
                die;
            }
        } else {
            echo "Database config file not found.";
            die;
        }
    } else {
        echo "No database config file.";
        die;
    }
    foreach ($config['databases'] as $key => $c) {
        if (!key_exists('model_directory_path', $c)) {
            echo CLI::failure("No 'model_directory_path' definition in database {$key}");
            return false;
        }
        $adapter = new Adapter($config['databases'], $c["adapter"]);
        if (key_exists('relationship_file', $c)) {
            $adapter->addFetcher(new Fetcher\PhpManyToManyFetcher($c["relationship_file"], $key));
        }
        switch ($c['adapter']) {
            case 'pgsql':
                $adapter->addFetcher(new Fetcher\PostgreSQLFetcher($key));
                break;
            default:
                break;
        }
        $adapter->fetch()->addGenerator(new Generator\RepelGenerator($c, $key))->generate();
        echo CLI::success();
    }
} catch (Exception $ex) {
    echo CLI::failure($ex);
Exemplo n.º 2
0
     echo CLI::color("done", green);
     echo "\n";
 }
 // Initializing structure
 echo CLI::dotFill('initializing', DOT_FILL);
 $manager->initialize();
 echo CLI::color("done", green);
 echo "\n";
 if ($old_schema !== null) {
     echo CLI::h1('copy data', HEADER_FILL);
     $public_schema_adapter = new Adapter\Adapter($config['databases'], $c['adapter']);
     $public_schema_adapter->addFetcher(new Adapter\Fetcher\PostgreSQLFetcher($key));
     $public_schema_adapter->fetch($manager->db);
     $old_config = $config['databases'];
     $old_config[$key]['schema_name'] = $old_schema;
     $old_schema_adapter = new Adapter\Adapter($old_config, $c['adapter']);
     $old_schema_adapter->addFetcher(new Adapter\Fetcher\PostgreSQLFetcher($key));
     $old_schema_adapter->fetch($manager->db);
     $copier = new Repel\Adapter\Copier\Copier($old_schema_adapter, $public_schema_adapter, $key, $key);
     $queries = $copier->copy($manager->db);
     file_put_contents(__DIR__ . '/update.sql', $queries);
     echo CLI::h1('initializing', HEADER_FILL);
     $initiator = new Initiator\Initiator($manager->db);
     $initiator->addSource(__DIR__ . '/update.sql');
     if (key_exists("views_dir", $c)) {
         echo CLI::dotFill('loading views', DOT_FILL);
         $views = array_merge(glob($c['views_dir'] . "/**/*.sql"), glob($c['views_dir'] . "/*.sql"));
         foreach ($views as $view) {
             $initiator->addSource($view);
         }
         echo CLI::color("done", green);