Files
panel/database/migrations/2017_02_10_171858_UpdateAPIKeyColumnNames.php

41 lines
1.2 KiB
PHP
Raw Normal View History

2017-02-10 17:29:10 -05:00
<?php
use Illuminate\Database\Migrations\Migration;
2025-09-24 13:34:19 +02:00
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
2017-02-10 17:29:10 -05:00
2024-03-19 21:03:50 -04:00
return new class extends Migration
2017-02-10 17:29:10 -05:00
{
/**
* Run the migrations.
*/
2024-03-19 21:12:27 -04:00
public function up(): void
2017-02-10 17:29:10 -05:00
{
Schema::table('api_keys', function (Blueprint $table) {
if (!in_array(Schema::getConnection()->getDriverName(), ['sqlite', 'pgsql'])) {
$table->dropForeign('api_keys_user_foreign');
$table->dropIndex('api_keys_user_foreign');
}
2017-02-10 17:29:10 -05:00
$table->renameColumn('user', 'user_id');
$table->foreign('user_id')->references('id')->on('users');
});
}
/**
* Reverse the migrations.
*/
2024-03-19 21:12:27 -04:00
public function down(): void
2017-02-10 17:29:10 -05:00
{
Schema::table('api_keys', function (Blueprint $table) {
if (!in_array(Schema::getConnection()->getDriverName(), ['sqlite', 'pgsql'])) {
$table->dropForeign('api_keys_user_id_foreign');
$table->dropIndex('api_keys_user_id_foreign');
}
2017-02-10 17:29:10 -05:00
$table->renameColumn('user_id', 'user');
$table->foreign('user')->references('id')->on('users');
});
}
2024-03-19 21:03:50 -04:00
};