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.
This commit is contained in:
Daeng Deni Mardaeni
2025-01-15 09:38:08 +07:00
parent b5c115a67e
commit f7ae8ea294

View File

@@ -1,32 +1,33 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Modules\Lpj\Models\Branch;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Modules\Basicdata\Models\Branch;
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');
});
}
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');
});
}
};