-
Notifications
You must be signed in to change notification settings - Fork 4
/
dumpTemplate.php
39 lines (35 loc) · 994 Bytes
/
dumpTemplate.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
37
38
39
<?php
/**
* This view is used by console/controllers/MigrateController.php
* The following variables are available in this view:
*/
/* @var $className string the new migration class name */
echo "<?php\n";
?>
use yii\db\Schema;
use yii\db\Migration;
use bariew\moduleMigration\DbHelper;
class <?= $className ?> extends Migration
{
public function up()
{
$sql = <<<SQL
<?= str_replace('$', '<$-sign>', $sql); ?>;
SQL;
DbHelper::foreignKeysOff();
if(<?= $remove; ?>) {
\Yii::$app->db->createCommand()->truncateTable('<?= $table; ?>')->execute();
}
\Yii::$app->db->createCommand(str_replace('<$-sign>', '$', $sql))->execute();
DbHelper::foreignKeysOn();
}
public function down()
{
DbHelper::foreignKeysOff();
if(<?= $remove; ?>) {
\Yii::$app->db->createCommand()->truncateTable('<?= $table; ?>')->execute();
}
DbHelper::foreignKeysOn();
return true;
}
}