Exemplo n.º 1
0
 private function migrate($name)
 {
     if (!isset($name) || "" === $name || array_search($name, $this->history)) {
         return;
     }
     $migration = DI::get($name);
     if (!isset($migration) || !$migration instanceof Migration) {
         return;
     }
     if (DB::transaction(function () use($migration, $name) {
         return false !== $migration->up();
     })) {
         $this->recordHistory($name);
         $this->clearTableSchema($name);
         Console::line("migrate {$name} finished.");
     } else {
         Console::line("migrate {$name} failure.");
     }
 }
Exemplo n.º 2
0
 public function forceDelete()
 {
     return DB::transaction(function () {
         if (false === $this->beforeDelete()) {
             return false;
         }
         if (false === $this->beforeForceDelete()) {
             return false;
         }
         $key = $this->schema->getAutoIncrementField();
         $result = DB::table($this->schema->getName())->where($key, $this->entity->{$key})->forceDelete()->execute();
         if ($result) {
             $this->afterDelete($this->fields());
         }
         if ($result) {
             $this->afterForceDelete($this->fields());
         }
         return $result;
     });
 }