Add a separate migration for the user name on the users table
This commit is contained in:
@@ -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();
|
||||||
|
|||||||
@@ -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');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user