pelican-panel-mirror/database/migrations/2017_03_03_224254_UpdateNodeConfigTokensColumns.php

43 lines
1.1 KiB
PHP

<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('node_configuration_tokens', function (Blueprint $table) {
if (Schema::getConnection()->getDriverName() !== 'sqlite') {
$table->dropForeign(['node']);
}
$table->dropColumn('expires_at');
$table->renameColumn('node', 'node_id');
$table->foreign('node_id')->references('id')->on('nodes');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('node_configuration_tokens', function (Blueprint $table) {
if (Schema::getConnection()->getDriverName() !== 'sqlite') {
$table->dropForeign(['node_id']);
}
$table->renameColumn('node_id', 'node');
$table->timestamp('expires_at')->after('token');
$table->foreign('node')->references('id')->on('nodes');
});
}
};