- Menambahkan index pada kolom province_code, city_code, district_code, dan code. - Meningkatkan performa query yang melibatkan kolom-kolom tersebut.
41 lines
1.1 KiB
PHP
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');
|
|
}
|
|
};
|