Merge branch 'develop' into feature/react-admin

This commit is contained in:
Matthew Penner 2021-02-07 16:16:22 -07:00
commit a87fef37ec
77 changed files with 1082 additions and 839 deletions

View file

@ -0,0 +1,42 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateAuditLogsTable extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('audit_logs', function (Blueprint $table) {
$table->id();
$table->char('uuid', 36);
$table->boolean('is_system')->default(false);
$table->unsignedInteger('user_id')->nullable();
$table->unsignedInteger('server_id')->nullable();
$table->string('action');
$table->string('subaction')->nullable();
$table->json('device');
$table->json('metadata');
$table->timestamp('created_at', 0);
$table->foreign('user_id')->references('id')->on('users')->onDelete('set null');
$table->foreign('server_id')->references('id')->on('servers')->onDelete('cascade');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::dropIfExists('audit_logs');
}
}

View file

@ -0,0 +1,55 @@
<?php
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
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');
});
}
}