2014-05-14 23:24:20 +10:00
|
|
|
<?php namespace System\Console;
|
|
|
|
|
2021-12-08 09:31:22 +08:00
|
|
|
use App;
|
2014-05-14 23:24:20 +10:00
|
|
|
use Illuminate\Console\Command;
|
|
|
|
use System\Classes\UpdateManager;
|
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
|
|
|
2017-03-16 17:08:20 +11:00
|
|
|
/**
|
|
|
|
* Console command to tear down the database.
|
|
|
|
*
|
2021-03-10 15:02:53 -06:00
|
|
|
* This destroys all database tables that are registered for Winter and all plugins.
|
2017-03-16 17:08:20 +11:00
|
|
|
*
|
2021-03-10 15:02:53 -06:00
|
|
|
* @package winter\wn-system-module
|
2017-03-16 17:08:20 +11:00
|
|
|
* @author Alexey Bobkov, Samuel Georges
|
|
|
|
*/
|
2021-03-10 15:02:53 -06:00
|
|
|
class WinterDown extends Command
|
2014-05-14 23:24:20 +10:00
|
|
|
{
|
2014-07-25 17:51:36 +10:00
|
|
|
use \Illuminate\Console\ConfirmableTrait;
|
|
|
|
|
2014-05-14 23:24:20 +10:00
|
|
|
/**
|
|
|
|
* The console command name.
|
|
|
|
*/
|
2021-03-10 15:02:53 -06:00
|
|
|
protected $name = 'winter:down';
|
2014-05-14 23:24:20 +10:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The console command description.
|
|
|
|
*/
|
2021-03-10 15:02:53 -06:00
|
|
|
protected $description = 'Destroys all database tables for Winter and all plugins.';
|
2014-05-14 23:24:20 +10:00
|
|
|
|
2021-04-03 08:39:45 -06:00
|
|
|
/**
|
|
|
|
* Create a new command instance.
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
// Register aliases for backwards compatibility with October
|
|
|
|
$this->setAliases(['october:down']);
|
|
|
|
}
|
|
|
|
|
2014-05-14 23:24:20 +10:00
|
|
|
/**
|
|
|
|
* Execute the console command.
|
|
|
|
*/
|
2017-07-14 16:28:47 +10:00
|
|
|
public function handle()
|
2014-05-14 23:24:20 +10:00
|
|
|
{
|
2021-12-08 09:31:22 +08:00
|
|
|
if (App::isProduction() && !$this->option('force')) {
|
|
|
|
$this->warn('YOUR APPLICATION IS IN PRODUCTION');
|
2014-10-18 11:58:50 +02:00
|
|
|
}
|
2014-05-14 23:24:20 +10:00
|
|
|
|
2021-12-08 09:31:22 +08:00
|
|
|
$this->warn('This will completely delete all database tables in use with your Winter installation.');
|
|
|
|
|
|
|
|
$confirmed = false;
|
|
|
|
$prompt = 'Please type "DELETE" to proceed';
|
|
|
|
do {
|
|
|
|
if (strtolower($this->ask($prompt)) === 'delete') {
|
|
|
|
$confirmed = true;
|
|
|
|
}
|
|
|
|
} while ($confirmed === false);
|
|
|
|
|
2017-05-20 09:03:58 +10:00
|
|
|
UpdateManager::instance()
|
|
|
|
->setNotesOutput($this->output)
|
|
|
|
->uninstall()
|
|
|
|
;
|
2014-05-14 23:24:20 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the console command options.
|
|
|
|
*/
|
|
|
|
protected function getOptions()
|
|
|
|
{
|
2014-07-25 17:51:36 +10:00
|
|
|
return [
|
2021-12-08 09:31:22 +08:00
|
|
|
['force', null, InputOption::VALUE_NONE, 'Force the operation to run and ignore production warning.'],
|
2014-07-25 17:51:36 +10:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the default confirmation callback.
|
|
|
|
* @return \Closure
|
|
|
|
*/
|
|
|
|
protected function getDefaultConfirmCallback()
|
|
|
|
{
|
2014-10-18 11:58:50 +02:00
|
|
|
return function () {
|
|
|
|
return true;
|
|
|
|
};
|
2014-05-14 23:24:20 +10:00
|
|
|
}
|
2014-10-18 11:58:50 +02:00
|
|
|
}
|