From f7ae8ea294f3db3340aea28ba1e37cf0b7c603ca Mon Sep 17 00:00:00 2001 From: Daeng Deni Mardaeni Date: Wed, 15 Jan 2025 09:38:08 +0700 Subject: [PATCH] fix(migration): perbaiki model Branch dan struktur migrasi pengguna - Memperbaiki import model Branch dari Modules\Basicdata\Models\Branch. - Menambahkan kolom 'nik' yang nullable setelah kolom 'email'. - Menambahkan foreign key untuk 'branch_id' yang nullable setelah kolom 'nik'. - Memperbaiki metode up dan down untuk migrasi pengguna. --- .../2024_08_27_071158_update_users_table.php | 57 ++++++++++--------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/database/migrations/2024_08_27_071158_update_users_table.php b/database/migrations/2024_08_27_071158_update_users_table.php index 8ae0073..4d4e0f8 100644 --- a/database/migrations/2024_08_27_071158_update_users_table.php +++ b/database/migrations/2024_08_27_071158_update_users_table.php @@ -1,32 +1,33 @@ string('nik')->nullable()->after('email'); - $table->foreignIdFor(Branch::class)->nullable()->after('nik')->constrained('branches'); - }); - } + return new class extends Migration { + /** + * Run the migrations. + */ + public function up() + : void + { + Schema::table('users', function (Blueprint $table) { + $table->string('nik')->nullable()->after('email'); + $table->foreignIdFor(Branch::class)->nullable()->after('nik')->constrained('branches'); + }); + } - /** - * Reverse the migrations. - */ - public function down(): void - { - Schema::table('users', function (Blueprint $table) { - $table->dropColumn('nik'); - $table->dropForeign(['branch_id']); - $table->dropColumn('branch_id'); - }); - } -}; + /** + * Reverse the migrations. + */ + public function down() + : void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('nik'); + $table->dropForeign(['branch_id']); + $table->dropColumn('branch_id'); + }); + } + };