Completed
Push — master ( 57ad4c...31fe35 )
by Freek
03:26 queued 01:40
created

Mysql::dropAllTables()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace Spatie\MigrateFresh\TableDroppers;
4
5
use DB;
6
use Schema;
7
use stdClass;
8
9
class Mysql implements TableDropper
10
{
11
    public function dropAllTables()
12
    {
13
        Schema::disableForeignKeyConstraints();
14
15
        collect(DB::select('SHOW TABLES'))
16
            ->map(function (stdClass $tableProperties) {
17
                return get_object_vars($tableProperties)[key($tableProperties)];
18
            })
19
            ->each(function (string $tableName) {
20
                Schema::drop($tableName);
21
            });
22
23
        Schema::enableForeignKeyConstraints();
24
    }
25
}
26