Ejemplo n.º 1
0
 private static function generateColumns(Template $template, Table $table)
 {
     /** @var Column $column */
     $columns = [];
     foreach ($table->getColumns() as $column) {
         $c = "'" . $column->getName() . "' => new Column(";
         $c .= "\n\t" . self::LINE_PREFIX . "\"" . $column->getName() . "\",\n";
         $c .= Generator::varExport($column->getDescription(), self::LINE_PREFIX . "\t");
         $c .= "\n" . self::LINE_PREFIX . ")";
         $columns[] = $c;
     }
     $template->set('columns', implode(",\n" . self::LINE_PREFIX, $columns));
 }
Ejemplo n.º 2
0
 public function generate()
 {
     echo "Generating Caribou MySQL migration\n";
     $version = "0.0.0";
     if (!is_dir($this->migrationsDir)) {
         echo "Creating migrations directory\n";
         mkdir($this->migrationsDir);
     } else {
         $content = scandir($this->migrationsDir);
         natsort($content);
         $content = array_reverse($content);
         foreach ($content as $c) {
             if (is_dir($this->migrationsDir . DIRECTORY_SEPARATOR . $c) && $c != "." && $c != "..") {
                 $version = $this->increaseVersion($c);
                 break;
             }
         }
     }
     Generator::generateVersion($version, $this->migrationsDir);
 }