mirror of
https://github.com/superhelio/commands.git
synced 2026-02-11 14:51:59 +00:00
Documentation, fixes and better messages
This commit is contained in:
@@ -32,7 +32,7 @@ class Gozer extends Command
|
|||||||
/**
|
/**
|
||||||
* Execute the console command.
|
* Execute the console command.
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle()
|
||||||
{
|
{
|
||||||
@@ -52,7 +52,7 @@ class Gozer extends Command
|
|||||||
\______ /\____/_____ \\___ >__|
|
\______ /\____/_____ \\___ >__|
|
||||||
\/ \/ \/
|
\/ \/ \/
|
||||||
|
|
||||||
');
|
');
|
||||||
|
|
||||||
$tables = [];
|
$tables = [];
|
||||||
|
|
||||||
@@ -70,7 +70,7 @@ class Gozer extends Command
|
|||||||
try {
|
try {
|
||||||
/** @var \Doctrine\DBAL\Schema\AbstractSchemaManager $connection */
|
/** @var \Doctrine\DBAL\Schema\AbstractSchemaManager $connection */
|
||||||
$connection = app('db')->connection()->getDoctrineSchemaManager();
|
$connection = app('db')->connection()->getDoctrineSchemaManager();
|
||||||
} catch (\Doctrine\DBAL\Driver\PDOException $e) {
|
} catch (\Exception $e) {
|
||||||
$this->error($e->getMessage());
|
$this->error($e->getMessage());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -108,28 +108,33 @@ class Gozer extends Command
|
|||||||
* Bid your farewells to these tables.
|
* Bid your farewells to these tables.
|
||||||
* Last look and confirmation.
|
* Last look and confirmation.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$this->info(sprintf(
|
$this->info(sprintf(
|
||||||
"Tables found:\n - %s",
|
"Tables found:\n - %s",
|
||||||
implode(",\n - ", $tables->toArray())
|
implode(",\n - ", $tables->toArray())
|
||||||
));
|
));
|
||||||
$this->line('');
|
$this->line('');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Last confirmation before dropping tables
|
||||||
|
*/
|
||||||
if ($this->confirm('Really delete those tables?')) {
|
if ($this->confirm('Really delete those tables?')) {
|
||||||
/**
|
|
||||||
* Fancy pants progress bar to see your tables get destroyed
|
/** Fancy pants progress bar to see your tables get destroyed */
|
||||||
*/
|
|
||||||
$bar = $this->output->createProgressBar($tables->count());
|
$bar = $this->output->createProgressBar($tables->count());
|
||||||
|
|
||||||
\Illuminate\Support\Facades\Schema::disableForeignKeyConstraints();
|
\Illuminate\Support\Facades\Schema::disableForeignKeyConstraints();
|
||||||
$tables->each(function ($table) use ($bar, $connection) {
|
$tables->each(function ($table) use ($bar, $connection) {
|
||||||
|
|
||||||
|
/** Drop the table */
|
||||||
$connection->dropTable($table);
|
$connection->dropTable($table);
|
||||||
|
|
||||||
|
/** Advance our progress bar */
|
||||||
$bar->advance();
|
$bar->advance();
|
||||||
|
|
||||||
});
|
});
|
||||||
\Illuminate\Support\Facades\Schema::enableForeignKeyConstraints();
|
\Illuminate\Support\Facades\Schema::enableForeignKeyConstraints();
|
||||||
|
|
||||||
|
/** Progress bar is now finished */
|
||||||
$bar->finish();
|
$bar->finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user