From 2b583551e3211d45e7efdfb61a41364f77457dc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yunus=20Emre=20Delig=C3=B6z?= Date: Wed, 15 May 2024 12:09:44 +0300 Subject: [PATCH] refactor(database): use static function keyword in database migration files Updated the database migrations to use 'static function' instead of 'function', following the best practice to avoid memory leaks, enhance performance, and improve code readability. The changes affect various tables including users, jobs, cache, oauth and tarfin cards. --- .../0001_01_01_000000_create_users_table.php | 6 +++--- .../0001_01_01_000001_create_cache_table.php | 4 ++-- .../migrations/0001_01_01_000002_create_jobs_table.php | 6 +++--- .../0001_01_01_000003_create_oauth_table.php | 10 +++++----- .../0001_01_01_000100_create_tarfin_cards_table.php | 2 +- ...01_000101_create_tarfin_card_transactions_table.php | 2 +- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/database/migrations/0001_01_01_000000_create_users_table.php b/database/migrations/0001_01_01_000000_create_users_table.php index 44c6d91..d0b021e 100644 --- a/database/migrations/0001_01_01_000000_create_users_table.php +++ b/database/migrations/0001_01_01_000000_create_users_table.php @@ -12,7 +12,7 @@ */ public function up(): void { - Schema::create(table: 'users', callback: function (Blueprint $table): void { + Schema::create(table: 'users', callback: static function (Blueprint $table): void { $table->id(); $table->string(column: 'name'); $table->string(column: 'email')->unique(); @@ -22,13 +22,13 @@ public function up(): void $table->timestamps(); }); - Schema::create(table: 'password_reset_tokens', callback: function (Blueprint $table): void { + Schema::create(table: 'password_reset_tokens', callback: static function (Blueprint $table): void { $table->string(column: 'email')->primary(); $table->string(column: 'token'); $table->timestamp(column: 'created_at')->nullable(); }); - Schema::create(table: 'sessions', callback: function (Blueprint $table): void { + Schema::create(table: 'sessions', callback: static function (Blueprint $table): void { $table->string(column: 'id')->primary(); $table->foreignId(column: 'user_id')->nullable()->index(); $table->string(column: 'ip_address', length: 45)->nullable(); diff --git a/database/migrations/0001_01_01_000001_create_cache_table.php b/database/migrations/0001_01_01_000001_create_cache_table.php index d827efc..6769136 100644 --- a/database/migrations/0001_01_01_000001_create_cache_table.php +++ b/database/migrations/0001_01_01_000001_create_cache_table.php @@ -12,13 +12,13 @@ */ public function up(): void { - Schema::create(table: 'cache', callback: function (Blueprint $table): void { + Schema::create(table: 'cache', callback: static function (Blueprint $table): void { $table->string(column: 'key')->primary(); $table->mediumText(column: 'value'); $table->integer(column: 'expiration'); }); - Schema::create(table: 'cache_locks', callback: function (Blueprint $table): void { + Schema::create(table: 'cache_locks', callback: static function (Blueprint $table): void { $table->string(column: 'key')->primary(); $table->string(column: 'owner'); $table->integer(column: 'expiration'); diff --git a/database/migrations/0001_01_01_000002_create_jobs_table.php b/database/migrations/0001_01_01_000002_create_jobs_table.php index 0472bc1..9ccd5f1 100644 --- a/database/migrations/0001_01_01_000002_create_jobs_table.php +++ b/database/migrations/0001_01_01_000002_create_jobs_table.php @@ -12,7 +12,7 @@ */ public function up(): void { - Schema::create(table: 'jobs', callback: function (Blueprint $table): void { + Schema::create(table: 'jobs', callback: static function (Blueprint $table): void { $table->id(); $table->string(column: 'queue')->index(); $table->longText(column: 'payload'); @@ -22,7 +22,7 @@ public function up(): void $table->unsignedInteger(column: 'created_at'); }); - Schema::create(table: 'job_batches', callback: function (Blueprint $table): void { + Schema::create(table: 'job_batches', callback: static function (Blueprint $table): void { $table->string(column: 'id')->primary(); $table->string(column: 'name'); $table->integer(column: 'total_jobs'); @@ -35,7 +35,7 @@ public function up(): void $table->integer(column: 'finished_at')->nullable(); }); - Schema::create(table: 'failed_jobs', callback: function (Blueprint $table): void { + Schema::create(table: 'failed_jobs', callback: static function (Blueprint $table): void { $table->id(); $table->string(column: 'uuid')->unique(); $table->text(column: 'connection'); diff --git a/database/migrations/0001_01_01_000003_create_oauth_table.php b/database/migrations/0001_01_01_000003_create_oauth_table.php index 5801715..a2a57d6 100644 --- a/database/migrations/0001_01_01_000003_create_oauth_table.php +++ b/database/migrations/0001_01_01_000003_create_oauth_table.php @@ -12,13 +12,13 @@ */ public function up(): void { - Schema::create(table: 'oauth_personal_access_clients', callback: function (Blueprint $table): void { + Schema::create(table: 'oauth_personal_access_clients', callback: static function (Blueprint $table): void { $table->bigIncrements(column: 'id'); $table->uuid(column: 'client_id'); $table->timestamps(); }); - Schema::create(table: 'oauth_auth_codes', callback: function (Blueprint $table): void { + Schema::create(table: 'oauth_auth_codes', callback: static function (Blueprint $table): void { $table->string(column: 'id', length: 100)->primary(); $table->unsignedBigInteger(column: 'user_id')->index(); $table->uuid(column: 'client_id'); @@ -27,7 +27,7 @@ public function up(): void $table->dateTime(column: 'expires_at')->nullable(); }); - Schema::create(table: 'oauth_access_tokens', callback: function (Blueprint $table): void { + Schema::create(table: 'oauth_access_tokens', callback: static function (Blueprint $table): void { $table->string(column: 'id', length: 100)->primary(); $table->unsignedBigInteger(column: 'user_id')->nullable()->index(); $table->uuid(column: 'client_id'); @@ -38,7 +38,7 @@ public function up(): void $table->dateTime(column: 'expires_at')->nullable(); }); - Schema::create(table: 'oauth_clients', callback: function (Blueprint $table): void { + Schema::create(table: 'oauth_clients', callback: static function (Blueprint $table): void { $table->uuid(column: 'id')->primary(); $table->unsignedBigInteger(column: 'user_id')->nullable()->index(); $table->string(column: 'name'); @@ -51,7 +51,7 @@ public function up(): void $table->timestamps(); }); - Schema::create(table: 'oauth_refresh_tokens', callback: function (Blueprint $table): void { + Schema::create(table: 'oauth_refresh_tokens', callback: static function (Blueprint $table): void { $table->string(column: 'id', length: 100)->primary(); $table->string(column: 'access_token_id', length: 100)->index(); $table->boolean(column: 'revoked'); diff --git a/database/migrations/0001_01_01_000100_create_tarfin_cards_table.php b/database/migrations/0001_01_01_000100_create_tarfin_cards_table.php index fe84130..7e37e54 100644 --- a/database/migrations/0001_01_01_000100_create_tarfin_cards_table.php +++ b/database/migrations/0001_01_01_000100_create_tarfin_cards_table.php @@ -13,7 +13,7 @@ */ public function up(): void { - Schema::create(table: 'tarfin_cards', callback: function (Blueprint $table): void { + Schema::create(table: 'tarfin_cards', callback: static function (Blueprint $table): void { $table->id(); $table->foreignIdFor(model: User::class)->constrained(); diff --git a/database/migrations/0001_01_01_000101_create_tarfin_card_transactions_table.php b/database/migrations/0001_01_01_000101_create_tarfin_card_transactions_table.php index 3e83a7f..7702d70 100644 --- a/database/migrations/0001_01_01_000101_create_tarfin_card_transactions_table.php +++ b/database/migrations/0001_01_01_000101_create_tarfin_card_transactions_table.php @@ -13,7 +13,7 @@ */ public function up(): void { - Schema::create(table: 'tarfin_card_transactions', callback: function (Blueprint $table): void { + Schema::create(table: 'tarfin_card_transactions', callback: static function (Blueprint $table): void { $table->id(); $table->foreignIdFor(model: TarfinCard::class)->constrained();