summaryrefslogtreecommitdiff
path: root/db/migrations/2018_01_01_000001_import_install_sql.php
diff options
context:
space:
mode:
Diffstat (limited to 'db/migrations/2018_01_01_000001_import_install_sql.php')
-rw-r--r--db/migrations/2018_01_01_000001_import_install_sql.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/db/migrations/2018_01_01_000001_import_install_sql.php b/db/migrations/2018_01_01_000001_import_install_sql.php
new file mode 100644
index 00000000..bd7ec7ae
--- /dev/null
+++ b/db/migrations/2018_01_01_000001_import_install_sql.php
@@ -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);
+ }
+ }
+ }
+}