2018-01-13 16:06:19 -06:00
|
|
|
<?php
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2018-01-13 16:06:19 -06:00
|
|
|
use Illuminate\Database\Migrations\Migration;
|
2026-10-05 18:10:18 -04:00
|
|
|
use Illuminate\Database\Schema\Blueprint;
|
|
|
|
|
use Illuminate\Support\Facades\Schema;
|
2018-01-13 16:06:19 -06:00
|
|
|
|
|
|
|
|
class SetupTableForKeyEncryption extends Migration
|
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* Run the migrations.
|
|
|
|
|
*
|
2024-10-21 19:18:20 -06:00
|
|
|
* @throws Exception
|
|
|
|
|
* @throws Throwable
|
2018-01-13 16:06:19 -06:00
|
|
|
*/
|
2024-10-21 19:18:20 -06:00
|
|
|
public function up(): void
|
2018-01-13 16:06:19 -06:00
|
|
|
{
|
2026-10-05 18:10:18 -04:00
|
|
|
Schema::table('api_keys', function (Blueprint $table): void {
|
2018-03-02 18:37:39 -06:00
|
|
|
$table->char('identifier', 16)->nullable()->unique()->after('user_id');
|
2018-01-13 16:06:19 -06:00
|
|
|
$table->dropUnique(['token']);
|
|
|
|
|
});
|
|
|
|
|
|
2026-10-05 18:10:18 -04:00
|
|
|
Schema::table('api_keys', function (Blueprint $table): void {
|
2018-01-13 16:06:19 -06:00
|
|
|
$table->text('token')->change();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Reverse the migrations.
|
|
|
|
|
*
|
2024-10-21 19:18:20 -06:00
|
|
|
* @throws Exception
|
|
|
|
|
* @throws Throwable
|
2018-01-13 16:06:19 -06:00
|
|
|
*/
|
2024-10-21 19:18:20 -06:00
|
|
|
public function down(): void
|
2018-01-13 16:06:19 -06:00
|
|
|
{
|
2026-10-05 18:10:18 -04:00
|
|
|
Schema::table('api_keys', function (Blueprint $table): void {
|
2018-01-13 16:06:19 -06:00
|
|
|
$table->dropColumn('identifier');
|
|
|
|
|
$table->string('token', 32)->unique()->change();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|