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) {
|
2025-03-30 14:44:03 -04:00
|
|
|
if (!in_array(Schema::getConnection()->getDriverName(), ['sqlite', 'pgsql'])) {
|
2024-05-11 20:09:22 -04:00
|
|
|
$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) {
|
2025-03-30 14:44:03 -04:00
|
|
|
if (!in_array(Schema::getConnection()->getDriverName(), ['sqlite', 'pgsql'])) {
|
2024-05-11 20:09:22 -04:00
|
|
|
$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
|
|
|
};
|