<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\Facades\DB;

return new class extends Migration
{
    public function up(): void
    {
        Schema::create('app_settings', function (Blueprint $table) {
            $table->id();
            $table->string('key')->unique();
            $table->string('value')->nullable();
            $table->string('description')->nullable();
            $table->timestamps();
        });

        DB::table('app_settings')->insert([
            [
                'key' => 'harga_per_m3', 
                'value' => '4000', 
                'description' => 'Harga air per meter kubik (Rp)',
                'created_at' => now(), 
                'updated_at' => now()
            ],
            [
                'key' => 'biaya_admin', 
                'value' => '2000', 
                'description' => 'Biaya administrasi bulanan (Rp)',
                'created_at' => now(), 
                'updated_at' => now()
            ],
            [
                'key' => 'is_upload_open', 
                'value' => '1', 
                'description' => 'Status portal upload meteran',
                'created_at' => now(), 
                'updated_at' => now()
            ],
        ]);
    }

    public function down(): void
    {
        Schema::dropIfExists('app_settings');
    }
};