Files
alliance-services/database/migrations/0001_01_01_000000_create_users_table.php
2026-03-06 11:18:15 -06:00

79 lines
2.5 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
if(!Schema::hasTable('users')) {
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->string('character_owner_hash')->index();
$table->string('character_name');
$table->unsignedBigInteger('character_id')->unique();
$table->text('token');
$table->text('refresh_token')->nullable();
$table->integer('expiresIn')->nullable();
// As requested: "user" holds jwt. (Note: naming a column "user" can be confusing later;
// consider "jwt" in future refactors, but this honors your spec.)
$table->text('user_jwt')->nullable();
$table->rememberToken();
$table->timestamps();
});
}
if(!Schema::hasTable('sessions')) {
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
$table->integer('last_activity')->index();
});
}
if(!Schema::hasTable('esi_token')) {
Schema::create('esi_token', function (Blueprint $table) {
$table->id();
$table->string('character_id');
$table->string('token');
$table->string('refresh_token');
$table->integer('expiresIn');
$table->string('user_jwt_token');
});
}
if(!Schema::hasTable('esi_scopes')) {
Schema::create('esi_scopes', function (Blueprint $table) {
$table->id();
$table->string('character_id');
$table->string('scope');
});
}
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users');
Schema::dropIfExists('password_reset_tokens');
Schema::dropIfExists('sessions');
Schema::dropIfExists('esi_token');
Schema::dropIfExists('esi_scopes');
}
};