|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Migratio\Resource\PushManager; |
|
4
|
|
|
|
|
5
|
|
|
use Migratio\SchemaCapsule; |
|
6
|
|
|
use Migratio\Resource\BaseManager; |
|
7
|
|
|
|
|
8
|
|
|
class Pushing extends BaseManager |
|
9
|
|
|
{ |
|
10
|
|
|
//get pushing |
|
11
|
|
|
use PushingProcess; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @var array |
|
15
|
|
|
*/ |
|
16
|
|
|
protected $list = array(); |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* pushing handle |
|
20
|
|
|
* |
|
21
|
|
|
* @return void|mixed |
|
22
|
|
|
*/ |
|
23
|
|
|
public function handle() |
|
24
|
|
|
{ |
|
25
|
|
|
foreach ($this->tableFilters() as $table=>$files){ |
|
26
|
|
|
|
|
27
|
|
|
$table = strtolower($table); |
|
28
|
|
|
|
|
29
|
|
|
foreach ($files as $file) { |
|
30
|
|
|
|
|
31
|
|
|
$checkMigrationMain = $this->schema->getConnection()->checkMigrationMain(); |
|
32
|
|
|
|
|
33
|
|
|
if($checkMigrationMain===false && isset($this->tableFilters()['Migrations'][0])){ |
|
34
|
|
|
$this->apply($this->tableFilters()['Migrations'][0],'migrations'); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
$checkMigration = $this->schema->getConnection()->checkMigration($table,$file); |
|
38
|
|
|
|
|
39
|
|
|
if(!$checkMigration){ |
|
40
|
|
|
|
|
41
|
|
|
$getClassName = preg_replace('@(\d+)_@is','',$file); |
|
42
|
|
|
$className = $this->getClassName($getClassName); |
|
43
|
|
|
|
|
44
|
|
|
require_once ($file); |
|
45
|
|
|
|
|
46
|
|
|
$capsule = new SchemaCapsule($this->config,$file,$table); |
|
47
|
|
|
|
|
48
|
|
|
$this->list[$table][] = (new $className)->up($capsule); |
|
49
|
|
|
|
|
50
|
|
|
} |
|
51
|
|
|
} |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
app()->register('arguments','connection',$this->schema->getConnection()); |
|
55
|
|
|
return $this->processHandler(); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @param $file |
|
60
|
|
|
* @param $table |
|
61
|
|
|
* @return mixed|string |
|
62
|
|
|
*/ |
|
63
|
|
|
public function apply($file,$table) |
|
64
|
|
|
{ |
|
65
|
|
|
$getClassName = preg_replace('@(\d+)_@is','',$file); |
|
66
|
|
|
$className = $this->getClassName($getClassName); |
|
67
|
|
|
|
|
68
|
|
|
require_once ($file); |
|
69
|
|
|
|
|
70
|
|
|
$capsule = new SchemaCapsule($this->config,$file,$table); |
|
71
|
|
|
|
|
72
|
|
|
$this->list[$table][] = (new $className)->up($capsule); |
|
73
|
|
|
|
|
74
|
|
|
return $this->processHandler(); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
|
|
78
|
|
|
} |