private function recordHistory($name) { $this->history[] = $name; Settings::save(App::path('migration_history'), serialize($this->history)); }
private function forgetMigration() { if (!isset($this->args[1])) { throw new ConsoleException("Invalid migration argument in [--forget]."); } $selectedIndex = intval($this->args[1]); $history = Settings::get(App::path('migration_history')); if (isset($history)) { $history = unserialize($history); if (!empty($history)) { $this->history = $history; $date = "Unknown datetime"; foreach ($this->history as $key => $value) { if ($key === $selectedIndex) { unset($this->history[$selectedIndex]); if (preg_match('#^m(?<timestamp>\\d+)#i', $value, $match)) { if (array_key_exists('timestamp', $match)) { $timestamp = intval($match['timestamp']); $date = date("Y-m-d H:i:s", $timestamp); } } Settings::save(App::path('migration_history'), serialize($this->history)); Console::line("{$key}.[{$date}][{$value}] has forget."); return; } } Console::line("Can't find index [{$selectedIndex}]."); return; } } Console::line("History is empty."); }