<?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
    {
        // Increase name length in price_settings
        Schema::table('price_settings', function (Blueprint $table) {
            $table->string('name', 20)->change();
        });

        // Increase nama_produk and jenis_barang length in stok_akhir
        Schema::table('stok_akhir', function (Blueprint $table) {
            $table->string('nama_produk', 20)->nullable()->change();
            $table->string('jenis_barang', 15)->nullable()->change();
        });

        // Increase nama_produk length in belanja
        Schema::table('belanja', function (Blueprint $table) {
            $table->string('nama_produk', 20)->change();
        });

        // Increase name length in customers
        Schema::table('customers', function (Blueprint $table) {
            $table->string('name', 35)->change();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('price_settings', function (Blueprint $table) {
            $table->string('name', 15)->change();
        });

        Schema::table('stok_akhir', function (Blueprint $table) {
            $table->string('nama_produk', 12)->nullable()->change();
            $table->string('jenis_barang', 12)->nullable()->change();
        });

        Schema::table('belanja', function (Blueprint $table) {
            $table->string('nama_produk', 12)->change();
        });

        Schema::table('customers', function (Blueprint $table) {
            $table->string('name', 20)->change();
        });
    }
};
