Files
location/database/migrations/2024_08_08_144309_create_villages_table.php
Daeng Deni Mardaeni d74dbb37a7 fix(migration): tambahkan index pada tabel villages
- Menambahkan index pada kolom province_code, city_code, district_code, dan code.
- Meningkatkan performa query yang melibatkan kolom-kolom tersebut.
2025-04-27 12:13:20 +07:00

41 lines
1.1 KiB
PHP

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('villages', function (Blueprint $table) {
$table->id();
$table->string('province_code')->index();
$table->string('city_code')->index();
$table->string('district_code')->index();
$table->string('code');
$table->string('name');
$table->string('alt_name')->nullable();
$table->string('postal_code', 5)->nullable();
$table->timestamps();
$table->softDeletes();
$table->uuid('created_by')->nullable();
$table->uuid('updated_by')->nullable();
$table->uuid('deleted_by')->nullable();
$table->index(['province_code', 'city_code', 'district_code','code']);
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('villages');
}
};