Files
panel-pelican-dev/database/migrations/2017_03_16_181109_ReOrganizeDatabaseServersToDatabaseHost.php

45 lines
1.2 KiB
PHP
Raw Normal View History

2017-03-16 19:35:29 -04:00
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
2024-03-19 21:03:50 -04:00
return new class extends Migration
2017-03-16 19:35:29 -04:00
{
/**
* Run the migrations.
*/
2024-03-19 21:12:27 -04:00
public function up(): void
2017-03-16 19:35:29 -04:00
{
Schema::table('database_servers', function (Blueprint $table) {
$table->dropForeign(['linked_node']);
});
2017-03-16 19:35:29 -04:00
Schema::rename('database_servers', 'database_hosts');
Schema::table('database_hosts', function (Blueprint $table) {
$table->renameColumn('linked_node', 'node_id');
$table->foreign('node_id')->references('id')->on('nodes');
});
}
/**
* Reverse the migrations.
*/
2024-03-19 21:12:27 -04:00
public function down(): void
2017-03-16 19:35:29 -04:00
{
Schema::table('database_hosts', function (Blueprint $table) {
$table->dropForeign(['node_id']);
});
2017-03-16 19:35:29 -04:00
Schema::rename('database_hosts', 'database_servers');
Schema::table('database_servers', function (Blueprint $table) {
$table->renameColumn('node_id', 'linked_node');
$table->foreign('linked_node')->references('id')->on('nodes');
});
}
2024-03-19 21:03:50 -04:00
};