database-pertani-web/database/migrations/2026_02_20_131504_create_lahans_table.php
2026-02-20 17:04:36 +07:00

67 lines
2.4 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('map_lahan', function (Blueprint $table) {
$table->id();
$table->string('nama');
$table->string('status_kepemilikan');
$table->foreignId('profile_id')->constrained('profiles');
$table->foreignId('keluarga_pengelola_id')->nullable()->constrained('keluarga')->onDelete('set null');
$table->foreignId('adat_pemilik_id')->nullable()->constrained('keluarga')->onDelete('set null');
$table->foreignId('desa_kelurahan_id')->nullable()->constrained('master_desa_kelurahan');
$table->text('path')->nullable();
$table->integer('luas_lahan')->nullable();
$table->foreignId('created_by')->nullable()->constrained('users')->onDelete('set null');
$table->foreignId('updated_by')->nullable()->constrained('users')->onDelete('set null');
$table->foreignId('deleted_by')->nullable()->constrained('users')->onDelete('set null');
$table->timestamps();
$table->softDeletes();
});
Schema::create('map_tanaman', function (Blueprint $table) {
$table->id();
$table->string('nama');
$table->foreignId('komoditas_id')->constrained('master_komoditas')->onDelete('set null');
$table->foreignId('profile_id')->constrained('profiles')->onDelete('set null');
$table->foreignId('lahan_id')->constrained('map_lahan')->onDelete('set null');
$table->float('latitude')->nullable();
$table->float('longitude')->nullable();
$table->string('kondisi_tanaman')->nullable();
$table->foreignId('created_by')->nullable()->constrained('users')->onDelete('set null');
$table->foreignId('updated_by')->nullable()->constrained('users')->onDelete('set null');
$table->foreignId('deleted_by')->nullable()->constrained('users')->onDelete('set null');
$table->timestamps();
$table->softDeletes();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('map_tanaman');
Schema::dropIfExists('map_lahan');
}
};