mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Fix confirmation, because apparently you can't pass that along via cli vs interactively
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
f35208d58d
commit
36464bc17d
|
@ -15,7 +15,7 @@ class PaveIt extends Command
|
||||||
*
|
*
|
||||||
* @var string
|
* @var string
|
||||||
*/
|
*/
|
||||||
protected $signature = 'snipeit:pave';
|
protected $signature = 'snipeit:pave {--force : Skip the interactive yes/no prompt for confirmation}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The console command description.
|
* The console command description.
|
||||||
|
@ -41,45 +41,51 @@ class PaveIt extends Command
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
if ($this->confirm("\n****************************************************\nTHIS WILL DELETE ALL OF THE DATA IN YOUR DATABASE. \nThere is NO undo. This WILL destroy ALL of your data. \n****************************************************\n\nDo you wish to continue? No backsies! [y|N]")) {
|
|
||||||
|
|
||||||
// List all the tables in the database so we don't have to worry about missing some as the app grows
|
if (!$this->option('force')) {
|
||||||
$tables = DB::connection()->getDoctrineSchemaManager()->listTableNames();
|
$confirmation = $this->confirm("\n****************************************************\nTHIS WILL DELETE ALL OF THE DATA IN YOUR DATABASE. \nThere is NO undo. This WILL destroy ALL of your data. \n****************************************************\n\nDo you wish to continue? No backsies! ");
|
||||||
|
if (!$confirmation) {
|
||||||
$except_tables = [
|
$this->error('ABORTING');
|
||||||
'oauth_access_tokens',
|
exit(-1);
|
||||||
'oauth_clients',
|
|
||||||
'oauth_personal_access_clients',
|
|
||||||
'migrations',
|
|
||||||
'settings',
|
|
||||||
'users',
|
|
||||||
];
|
|
||||||
|
|
||||||
// We only need to find out what these are so we can nuke these columns on the assets table.
|
|
||||||
$custom_fields = CustomField::get();
|
|
||||||
foreach ($custom_fields as $custom_field) {
|
|
||||||
$this->info('Drop the '.$custom_field->db_column.' column from assets as well.');
|
|
||||||
|
|
||||||
if (\Schema::hasColumn('assets', $custom_field->db_column)) {
|
|
||||||
\Schema::table('assets', function ($table) use ($custom_field) {
|
|
||||||
$table->dropColumn($custom_field->db_column);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($tables as $table) {
|
|
||||||
if (in_array($table, $except_tables)) {
|
|
||||||
$this->info('Table '. $table. ' is skipped');
|
|
||||||
} else {
|
|
||||||
\DB::statement('truncate '.$table);
|
|
||||||
$this->info('Table '. $table. ' is truncated');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Leave in the demo oauth keys so we don't have to reset them every day in the demos
|
|
||||||
//\DB::statement('delete from users WHERE id > 2');
|
|
||||||
\DB::statement('delete from oauth_clients WHERE id > 2');
|
|
||||||
\DB::statement('delete from oauth_access_tokens WHERE id > 2');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// List all the tables in the database so we don't have to worry about missing some as the app grows
|
||||||
|
$tables = DB::connection()->getDoctrineSchemaManager()->listTableNames();
|
||||||
|
|
||||||
|
$except_tables = [
|
||||||
|
'oauth_access_tokens',
|
||||||
|
'oauth_clients',
|
||||||
|
'oauth_personal_access_clients',
|
||||||
|
'migrations',
|
||||||
|
'settings',
|
||||||
|
'users',
|
||||||
|
];
|
||||||
|
|
||||||
|
// We only need to find out what these are so we can nuke these columns on the assets table.
|
||||||
|
$custom_fields = CustomField::get();
|
||||||
|
foreach ($custom_fields as $custom_field) {
|
||||||
|
$this->info('DROP the '.$custom_field->db_column.' column from assets as well.');
|
||||||
|
|
||||||
|
if (\Schema::hasColumn('assets', $custom_field->db_column)) {
|
||||||
|
\Schema::table('assets', function ($table) use ($custom_field) {
|
||||||
|
$table->dropColumn($custom_field->db_column);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($tables as $table) {
|
||||||
|
if (in_array($table, $except_tables)) {
|
||||||
|
$this->info($table. ' is SKIPPED.');
|
||||||
|
} else {
|
||||||
|
\DB::statement('truncate '.$table);
|
||||||
|
$this->info($table. ' is TRUNCATED.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Leave in the demo oauth keys so we don't have to reset them every day in the demos
|
||||||
|
\DB::statement('delete from oauth_clients WHERE id > 2');
|
||||||
|
\DB::statement('delete from oauth_access_tokens WHERE id > 2');
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue