Exemplo n.º 1
0
 public function handle($request)
 {
     parent::handle($request);
     $this->loadMigrationParameters();
     $filename = 'db-migration.yml';
     $source = __DIR__ . '/../../../' . $filename;
     $dest = getcwd() . '/' . $filename;
     if (!is_file($dest)) {
         if (copy($source, $dest)) {
             echo "{$filename} is created\n";
         } else {
             throw new \Exception("Can't create {$filename}. Check permissions?");
         }
     } else {
         echo "{$filename} already exists\n";
     }
     foreach ($this->app->parameters['migrations'] as $path) {
         echo $path . ' ';
         if (!is_dir(getcwd() . '/' . $path)) {
             if (mkdir($path, 0777, true)) {
                 echo "created\n";
             } else {
                 throw new \Exception("Can't create migrations folder. Check permissions?");
             }
         } else {
             echo "already exists\n";
         }
     }
 }
Exemplo n.º 2
0
 public function handle($request)
 {
     parent::handle($request);
     $this->initTracker();
     $date = date('Y-m-d');
     $number = 1;
     $last_migration = $this->getLastMigrationParsedId();
     if ($last_migration) {
         if ($date == $last_migration['date']) {
             $number = $last_migration['number'] + 1;
         }
     }
     $migration_filename = sprintf('%s-%s', $date, str_pad($number, 3, '0', STR_PAD_LEFT));
     $words = $this->app->parameters['_words_'];
     $name = false;
     if (isset($words[2])) {
         $name = $words[2];
     }
     if ($name !== false) {
         $name = preg_replace('/[^\\w]/', '-', $name);
         $migration_filename .= '-' . $name;
     }
     $migration_filename .= '.' . $this->app->parameters['migration-file-extention'];
     $migration_fullname = $this->app->parameters['pwd'] . $this->app->parameters['migrations'][0] . $migration_filename;
     if (file_put_contents($migration_fullname, '') !== false) {
         echo "Created empty migration file {$migration_filename}\n";
     } else {
         throw new \Exception('Can\'t create new migration file');
     }
 }
Exemplo n.º 3
0
 public function handle($request)
 {
     parent::handle($request);
     $this->initTracker();
     $migrations = $this->app->getTrackedMigrations();
     foreach ($migrations as $migration) {
         if ($migration->status == 'new') {
             $this->printMigration($migration);
         }
     }
 }
Exemplo n.º 4
0
 public function handle($request)
 {
     parent::handle($request);
     $this->initTracker();
     $limit = null;
     $words = $this->app->parameters['_words_'];
     if (isset($words[2])) {
         $limit = $words[2];
     }
     $migrations = $this->app->getTrackedMigrations($limit);
     foreach ($migrations as $migration) {
         $this->printMigration($migration);
     }
 }
 public function handle($request)
 {
     parent::handle($request);
     $this->initTracker();
     $migrations = $this->app->getTrackedMigrations();
     $tracker = $this->app->getTracker();
     $cnt = 0;
     foreach ($migrations as $migration) {
         if (!in_array($migration->status, array('new', 'migrated'))) {
             $this->printMigration($migration);
             $tracker->delete($migration);
             $cnt++;
         }
     }
     echo "All unlocked\n";
 }
 public function handle($request)
 {
     parent::handle($request);
     $this->initTracker();
     $migrations = $this->app->getTrackedMigrations();
     $tracker = $this->app->getTracker();
     $cnt = 0;
     foreach ($migrations as $migration) {
         $this->printMigration($migration);
         if ($migration->status == 'new') {
             $tracker->register($migration);
             $tracker->setStatus($migration, 'migrated');
             echo "Marked as migrated\n";
         }
         $cnt++;
     }
     echo "All migrated\n";
 }
Exemplo n.º 7
0
 public function handle($request)
 {
     parent::handle($request);
     $this->initTracker();
     $mirations = $this->app->getTrackedMigrations();
     $tracker = $this->app->getTracker();
     $cnt = 0;
     $words = $this->app->parameters['_words_'];
     if (!isset($words[2])) {
         throw new \Exception("Must specify migration id", 1);
     }
     $reset_id = $words[2];
     foreach ($mirations as $migration) {
         if ($migration->id == $reset_id) {
             $this->printMigration($migration);
             $tracker->delete($migration);
             $cnt++;
         }
     }
     if ($cnt == 0) {
         throw new \Exception("migration not found '{$reset_id}'", 1);
     }
 }