|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Helldar\Roles\Support\Database; |
|
4
|
|
|
|
|
5
|
|
|
use Closure; |
|
6
|
|
|
use Helldar\Roles\Facades\Config; |
|
7
|
|
|
use Illuminate\Database\Migrations\Migration; |
|
8
|
|
|
use Illuminate\Database\Schema\Builder; |
|
9
|
|
|
use Illuminate\Support\Facades\Schema; |
|
10
|
|
|
|
|
11
|
|
|
abstract class BaseMigration extends Migration |
|
12
|
|
|
{ |
|
13
|
|
|
protected $permissions = 'permissions'; |
|
14
|
|
|
|
|
15
|
|
|
protected $role_permission = 'role_permission'; |
|
16
|
|
|
|
|
17
|
|
|
protected $role_permissions = 'role_permissions'; |
|
18
|
|
|
|
|
19
|
|
|
protected $roles = 'roles'; |
|
20
|
|
|
|
|
21
|
|
|
protected $user_permission = 'user_permission'; |
|
22
|
|
|
|
|
23
|
|
|
protected $user_role = 'user_role'; |
|
24
|
|
|
|
|
25
|
|
|
protected $user_roles = 'user_roles'; |
|
26
|
|
|
|
|
27
|
|
|
protected $users = 'users'; |
|
28
|
|
|
|
|
29
|
|
|
abstract public function up(); |
|
30
|
|
|
|
|
31
|
|
|
abstract public function down(); |
|
32
|
|
|
|
|
33
|
48 |
|
protected function schema(): Builder |
|
34
|
|
|
{ |
|
35
|
48 |
|
return Schema::connection( |
|
36
|
48 |
|
Config::connection() |
|
37
|
|
|
); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
48 |
|
protected function create(string $table, Closure $callback) |
|
41
|
|
|
{ |
|
42
|
48 |
|
$this->schema()->create($table, $callback); |
|
43
|
48 |
|
} |
|
44
|
|
|
|
|
45
|
|
|
protected function drop(string $table) |
|
46
|
|
|
{ |
|
47
|
|
|
$this->schema()->dropIfExists($table); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
48 |
|
protected function table(string $table, Closure $callback) |
|
51
|
|
|
{ |
|
52
|
48 |
|
$this->schema()->table($table, $callback); |
|
53
|
48 |
|
} |
|
54
|
|
|
|
|
55
|
48 |
|
protected function rename(string $from, string $to) |
|
56
|
|
|
{ |
|
57
|
48 |
|
$this->schema()->rename($from, $to); |
|
58
|
48 |
|
} |
|
59
|
|
|
|
|
60
|
|
|
protected function dropTables(...$tables) |
|
61
|
|
|
{ |
|
62
|
|
|
foreach ($tables as $table) { |
|
63
|
|
|
$this->drop($table); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
} |
|
67
|
|
|
|