Mojopollo\Schema\Commands\MakeMigrationJsonCommand::undo PHP Method

undo() protected method

Perform undo action
protected undo ( ) : void
return void
    protected function undo()
    {
        // Delete status
        $deleteCompleted = true;
        // Get files from the json undo file
        $files = json_decode($this->filesystem->get($this->undoFilePath), true);
        // For each file
        $this->info('Deleting files:');
        foreach ($files as $file) {
            // If this file can be deleted
            if ($this->filesystem->isWritable($file)) {
                // Delete it
                $this->filesystem->delete($file);
                $this->info("  Deleted: {$file}");
            } else {
                // Set status
                $deleteCompleted = false;
                // Show error
                $this->error('Could not delete: ' . $file);
            }
        }
        // if the delete prccess finished successfully
        if ($deleteCompleted) {
            // Delete undo file
            $this->filesystem->delete($this->undoFilePath);
        }
    }