diff options
author | msquare <msquare@notrademark.de> | 2019-12-08 11:48:58 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-08 11:48:58 +0100 |
commit | a3a938a1210f1bfb2680c25b2bcf53e47444bdba (patch) | |
tree | fd4c13fd9b714c0d8c60b6d3fe3e2fc88b82b717 /db/migrations/2019_09_07_000001_create_schedule_shift_table.php | |
parent | b540ac93856065ce6e145930b6611e0a0946d646 (diff) | |
parent | 064a1750279be244f86cf24f29749b391b11f1dd (diff) |
Merge pull request #685 from MyIgel/schedule-import
Rebuild Schedule import
Diffstat (limited to 'db/migrations/2019_09_07_000001_create_schedule_shift_table.php')
-rw-r--r-- | db/migrations/2019_09_07_000001_create_schedule_shift_table.php | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/db/migrations/2019_09_07_000001_create_schedule_shift_table.php b/db/migrations/2019_09_07_000001_create_schedule_shift_table.php new file mode 100644 index 00000000..c9cd7cfe --- /dev/null +++ b/db/migrations/2019_09_07_000001_create_schedule_shift_table.php @@ -0,0 +1,90 @@ +<?php + +namespace Engelsystem\Migrations; + +use Engelsystem\Database\Migration\Migration; +use Illuminate\Database\Schema\Blueprint; + +class CreateScheduleShiftTable extends Migration +{ + use Reference; + + /** + * Run the migration + */ + public function up() + { + $this->schema->create( + 'schedules', + function (Blueprint $table) { + $table->increments('id'); + $table->string('url'); + } + ); + + $this->schema->create( + 'schedule_shift', + function (Blueprint $table) { + $table->integer('shift_id')->index()->unique(); + if ($this->schema->hasTable('Shifts')) { + // Legacy table access + $table->foreign('shift_id') + ->references('SID')->on('Shifts') + ->onUpdate('cascade') + ->onDelete('cascade'); + } + + $this->references($table, 'schedules'); + $table->uuid('guid'); + } + ); + + if ($this->schema->hasTable('Shifts')) { + $this->schema->table( + 'Shifts', + function (Blueprint $table) { + $table->dropColumn('PSID'); + } + ); + } + + if ($this->schema->hasTable('Room')) { + $this->schema->table( + 'Room', + function (Blueprint $table) { + $table->dropColumn('from_frab'); + } + ); + } + } + + /** + * Reverse the migration + */ + public function down() + { + if ($this->schema->hasTable('Room')) { + $this->schema->table( + 'Room', + function (Blueprint $table) { + $table->boolean('from_frab') + ->default(false); + } + ); + } + + if ($this->schema->hasTable('Shifts')) { + $this->schema->table( + 'Shifts', + function (Blueprint $table) { + $table->integer('PSID') + ->nullable()->default(null) + ->unique(); + } + ); + } + + $this->schema->drop('schedule_shift'); + $this->schema->drop('schedules'); + } +} |