/** * Delete scheduled task. */ public function actionDelete() { if ($this->scheduleId === null) { $this->actionList(); $this->scheduleId = $this->prompt('Enter ID of the scheduled task to delete:', ['required' => true]); } $model = Schedule::findOne(intval($this->scheduleId)); if (!$model) { throw new Exception('Schedule with ID ' . $this->scheduleId . ' not found.'); return Controller::EXIT_CODE_ERROR; } if (!$this->confirm('Are you sure you want to permanently delete this record?')) { $this->log('Delete aborted by user.'); return Controller::EXIT_CODE_NORMAL; } if ($model->delete()) { $this->warning('Schedule with ID ' . $this->scheduleId . ' successfully deleted.'); return Controller::EXIT_CODE_NORMAL; } else { $this->log('Schedule with ID ' . $this->scheduleId . ' was not deleted.'); return Controller::EXIT_CODE_ERROR; } }
public function down() { $this->dropTable(Schedule::tableName()); }