Refactor user and session migrations to use UUIDs; update DatabaseSeeder for test user creation; enhance LetterController with search functionality and API route protection

This commit is contained in:
NoBody313
2025-03-24 11:26:00 +07:00
parent 6d431d9610
commit e7477e204f
9 changed files with 559 additions and 127 deletions
@@ -12,7 +12,7 @@ return new class extends Migration
public function up(): void
{
Schema::create('users', function (Blueprint $table) {
$table->id();
$table->uuid('id')->primary();
$table->string('name');
$table->string('email')->unique();
$table->timestamp('email_verified_at')->nullable();
@@ -29,7 +29,8 @@ return new class extends Migration
Schema::create('sessions', function (Blueprint $table) {
$table->string('id')->primary();
$table->foreignId('user_id')->nullable()->index();
$table->uuid('user_id')->nullable()->index();
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
$table->string('ip_address', 45)->nullable();
$table->text('user_agent')->nullable();
$table->longText('payload');
@@ -13,7 +13,7 @@ return new class extends Migration
{
Schema::create('personal_access_tokens', function (Blueprint $table) {
$table->id();
$table->morphs('tokenable');
$table->uuidMorphs('tokenable');
$table->string('name');
$table->string('token', 64)->unique();
$table->text('abilities')->nullable();
+1 -2
View File
@@ -13,11 +13,10 @@ class DatabaseSeeder extends Seeder
*/
public function run(): void
{
// User::factory(10)->create();
User::factory()->create([
'name' => 'Test User',
'email' => 'test@example.com',
'password' => bcrypt('password')
]);
}
}