<?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('user_preferences', function (Blueprint $table) {
            // Drop these columns
            $table->dropColumn([
                'height_cm',
                'height_ft',
                'weight_kg',
                'weight_lbs',
            ]);

            // Add these columns
            $table->string('from_height_cm')->nullable();
            $table->string('to_height_cm')->nullable();
            $table->string('from_height_ft')->nullable();
            $table->string('to_height_ft')->nullable();
            $table->string('from_weight_kg')->nullable();
            $table->string('from_weight_lbs')->nullable();
            $table->string('to_weight_kg')->nullable();
            $table->string('to_weight_lbs')->nullable();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('user_preferences', function (Blueprint $table) {
            // Add back dropped columns
            $table->string('height_cm')->nullable();
            $table->string('height_ft')->nullable();
            $table->string('weight_kg')->nullable();
            $table->string('weight_lbs')->nullable();

            // Drop the newly added columns
            $table->dropColumn([
                'from_height_cm',
                'to_height_cm',
                'from_height_ft',
                'to_height_ft',
                'from_weight_kg',
                'from_weight_lbs',
                'to_weight_kg',
                'to_weight_lbs',
            ]);
        });
    }
};
