-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAttacher.php
36 lines (29 loc) · 841 Bytes
/
Attacher.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/**
*/
namespace execut\alias;
use execut\yii\migration\Inverter;
use execut\yii\migration\Migration;
use yii\base\Exception;
class Attacher extends \execut\yii\migration\Attacher
{
public $tables = [];
protected function getVariations () {
return ['tables'];
}
public function initInverter(Inverter $i) {
foreach ($this->tables as $table) {
$tableSchema = $this->db->getTableSchema($table);
if (!$tableSchema) {
throw new Exception('Not found table ' . $table);
}
$isAttached = $tableSchema->getColumn('alias');
if (!$isAttached) {
$helper = new MigrationHelper([
'table' => $this->table($table)
]);
$helper->attach();
}
}
}
}