2017-02-03 21:50:28 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
use Illuminate\Database\Migrations\Migration;
|
|
|
|
|
|
|
|
class RenameColumns extends Migration
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*/
|
2022-11-25 20:29:04 +00:00
|
|
|
public function up(): void
|
2017-02-03 21:50:28 +00:00
|
|
|
{
|
|
|
|
Schema::table('allocations', function (Blueprint $table) {
|
2022-11-25 20:29:04 +00:00
|
|
|
$table->dropForeign(['node']);
|
|
|
|
$table->dropForeign(['assigned_to']);
|
2017-02-03 21:50:28 +00:00
|
|
|
|
|
|
|
$table->renameColumn('node', 'node_id');
|
|
|
|
$table->renameColumn('assigned_to', 'server_id');
|
|
|
|
$table->foreign('node_id')->references('id')->on('nodes');
|
|
|
|
$table->foreign('server_id')->references('id')->on('servers');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*/
|
2022-11-25 20:29:04 +00:00
|
|
|
public function down(): void
|
2017-02-03 21:50:28 +00:00
|
|
|
{
|
|
|
|
Schema::table('allocations', function (Blueprint $table) {
|
2022-11-25 20:29:04 +00:00
|
|
|
$table->dropForeign(['node_id']);
|
|
|
|
$table->dropForeign(['server_id']);
|
|
|
|
$table->dropIndex(['node_id']);
|
|
|
|
$table->dropIndex(['server_id']);
|
2017-02-03 21:50:28 +00:00
|
|
|
|
|
|
|
$table->renameColumn('node_id', 'node');
|
|
|
|
$table->renameColumn('server_id', 'assigned_to');
|
|
|
|
$table->foreign('node')->references('id')->on('nodes');
|
|
|
|
$table->foreign('assigned_to')->references('id')->on('servers');
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|