Remove suspended & installing fields, replace with single status field
This commit is contained in:
parent
4c29be2e54
commit
a75a347d65
24 changed files with 115 additions and 59 deletions
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddGenericServerStatusColumn extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('servers', function (Blueprint $table) {
|
||||
$table->string('status')->nullable()->after('description');
|
||||
});
|
||||
|
||||
DB::transaction(function () {
|
||||
DB::update('UPDATE servers SET `status` = \'suspended\' WHERE `suspended` = 1');
|
||||
DB::update('UPDATE servers SET `status` = \'installing\' WHERE `installed` = 0');
|
||||
DB::update('UPDATE servers SET `status` = \'install_failed\' WHERE `installed` = 2');
|
||||
});
|
||||
|
||||
Schema::table('servers', function (Blueprint $table) {
|
||||
$table->dropColumn('suspended');
|
||||
$table->dropColumn('installed');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('servers', function (Blueprint $table) {
|
||||
$table->unsignedTinyInteger('suspended')->default(0);
|
||||
$table->unsignedTinyInteger('installed')->default(0);
|
||||
});
|
||||
|
||||
DB::transaction(function () {
|
||||
DB::update('UPDATE servers SET `suspended` = 1 WHERE `status` = \'suspended\'');
|
||||
DB::update('UPDATE servers SET `installed` = 1 WHERE `status` IS NULL');
|
||||
DB::update('UPDATE servers SET `installed` = 2 WHERE `status` = \'install_failed\'');
|
||||
});
|
||||
|
||||
Schema::table('servers', function (Blueprint $table) {
|
||||
$table->dropColumn('status');
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue