2017-02-02 23:21:36 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
|
|
|
|
class UpdateColumnNames extends Migration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*/
|
2022-11-25 20:29:04 +00:00
|
|
|
public function up(): void
|
2017-02-02 23:21:36 +00:00
|
|
|
{
|
|
|
|
Schema::table('servers', function (Blueprint $table) {
|
2022-11-25 20:29:04 +00:00
|
|
|
$table->dropForeign(['node']);
|
|
|
|
$table->dropForeign(['owner']);
|
|
|
|
$table->dropForeign(['allocation']);
|
|
|
|
$table->dropForeign(['service']);
|
|
|
|
$table->dropForeign(['option']);
|
|
|
|
$table->dropForeign(['pack']);
|
2017-02-02 23:21:36 +00:00
|
|
|
|
|
|
|
$table->renameColumn('node', 'node_id');
|
|
|
|
$table->renameColumn('owner', 'owner_id');
|
|
|
|
$table->renameColumn('allocation', 'allocation_id');
|
|
|
|
$table->renameColumn('service', 'service_id');
|
|
|
|
$table->renameColumn('option', 'option_id');
|
|
|
|
$table->renameColumn('pack', 'pack_id');
|
|
|
|
|
|
|
|
$table->foreign('node_id')->references('id')->on('nodes');
|
|
|
|
$table->foreign('owner_id')->references('id')->on('users');
|
|
|
|
$table->foreign('allocation_id')->references('id')->on('allocations');
|
|
|
|
$table->foreign('service_id')->references('id')->on('services');
|
|
|
|
$table->foreign('option_id')->references('id')->on('service_options');
|
2017-04-19 22:43:32 +00:00
|
|
|
|
|
|
|
// Pack ID was forgotten until multiple releases later, therefore it is
|
|
|
|
// contained in '2017_03_18_204953_AddForeignKeyToPacks'
|
2017-02-02 23:21:36 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*/
|
2022-11-25 20:29:04 +00:00
|
|
|
public function down(): void
|
2017-02-02 23:21:36 +00:00
|
|
|
{
|
|
|
|
Schema::table('servers', function (Blueprint $table) {
|
2022-11-25 20:29:04 +00:00
|
|
|
$table->dropForeign(['node_id', 'owner_id', 'allocation_id', 'service_id', 'option_id']);
|
2017-02-02 23:25:11 +00:00
|
|
|
|
2017-02-02 23:21:36 +00:00
|
|
|
$table->renameColumn('node_id', 'node');
|
|
|
|
$table->renameColumn('owner_id', 'owner');
|
|
|
|
$table->renameColumn('allocation_id', 'allocation');
|
|
|
|
$table->renameColumn('service_id', 'service');
|
|
|
|
$table->renameColumn('option_id', 'option');
|
|
|
|
$table->renameColumn('pack_id', 'pack');
|
|
|
|
|
|
|
|
$table->foreign('node')->references('id')->on('nodes');
|
|
|
|
$table->foreign('owner')->references('id')->on('users');
|
|
|
|
$table->foreign('allocation')->references('id')->on('allocations');
|
|
|
|
$table->foreign('service')->references('id')->on('services');
|
|
|
|
$table->foreign('option')->references('id')->on('service_options');
|
2017-04-19 22:43:32 +00:00
|
|
|
$table->foreign('pack')->references('id')->on('service_packs');
|
2017-02-02 23:21:36 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|