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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<?php
namespace Engelsystem\Migrations;
use Engelsystem\Database\Migration\Migration;
class ImportInstallSql extends Migration
{
protected $oldTables = [
'AngelTypes',
'EventConfig',
'GroupPrivileges',
'Groups',
'LogEntries',
'Messages',
'NeededAngelTypes',
'News',
'NewsComments',
'Privileges',
'Questions',
'Room',
'ShiftEntry',
'Shifts',
'ShiftTypes',
'User',
'UserAngelTypes',
'UserDriverLicenses',
'UserGroups',
];
/**
* Run the migration
*/
public function up()
{
foreach ($this->oldTables as $table) {
if ($this->schema->hasTable($table)) {
return;
}
}
$sql = file_get_contents(__DIR__ . '/../install.sql');
$this->schema->getConnection()->unprepared($sql);
}
/**
* Reverse the migration
*/
public
function down()
{
$this->schema->getConnection()->statement('SET FOREIGN_KEY_CHECKS=0;');
foreach ($this->oldTables as $table) {
if ($this->schema->hasTable($table)) {
$this->schema->dropIfExists($table);
}
}
}
}
|