Add a separate migration for the user name on the users table

This commit is contained in:
2026-03-19 12:03:47 +01:00
parent 124c707634
commit a373b60750
2 changed files with 31 additions and 1 deletions

View File

@@ -17,7 +17,6 @@ public function up(): void
$table->id(); $table->id();
$table->foreignId('role_id')->default(1)->constrained(); $table->foreignId('role_id')->default(1)->constrained();
$table->string('name'); $table->string('name');
$table->string('username')->unique();
$table->string('email')->unique(); $table->string('email')->unique();
$table->string('azure_id')->nullable()->unique(); $table->string('azure_id')->nullable()->unique();
$table->string('photo')->nullable(); $table->string('photo')->nullable();

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Add the username column to the users table.
* Nullable to allow existing users to exist without a username.
*/
public function up(): void
{
Schema::table('users', function (Blueprint $table): void {
$table->string('username')->unique()->nullable()->after('name');
});
}
/**
* Remove the username column from the users table.
*/
public function down(): void
{
Schema::table('users', function (Blueprint $table): void {
$table->dropColumn('username');
});
}
};