<?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::table('obat_keluars', function (Blueprint $table) {
            $table->foreignId('obat_masuk_id')->nullable()->after('id')->constrained('obat_masuks')->nullOnDelete();
            $table->string('nama_obat')->nullable()->after('obat_masuk_id');
            $table->renameColumn('keterangan', 'catatan');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('obat_keluars', function (Blueprint $table) {
            $table->dropForeign(['obat_masuk_id']);
            $table->dropColumn('obat_masuk_id');
            $table->dropColumn('nama_obat');
            $table->renameColumn('catatan', 'keterangan');
        });
    }
};
