Installation: Added migrations for install.sql and update.sql files
parent
5456fea503
commit
9d9aa71eb7
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Engelsystem\Database\Migration\Migration;
|
||||
|
||||
class ImportUpdateSql extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if ($this->schema->hasTable('UserWorkLog')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$sql = file_get_contents(__DIR__ . '/../update.sql');
|
||||
$this->schema->getConnection()->unprepared($sql);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migration
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
$this->schema->dropIfExists('UserWorkLog');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue