<?php

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

return new class extends Migration
{
    public function up(): void
    {
        Schema::table('membership_plans', function (Blueprint $table) {
            if (!Schema::hasColumn('membership_plans', 'trial_days')) {
                $table->unsignedSmallInteger('trial_days')->default(0)->after('duration_days');
            }
        });

        Schema::table('users', function (Blueprint $table) {
            if (!Schema::hasColumn('users', 'profile_music_url')) {
                $table->string('profile_music_url', 500)->nullable();
            }
        });
    }

    public function down(): void
    {
        Schema::table('membership_plans', function (Blueprint $table) {
            if (Schema::hasColumn('membership_plans', 'trial_days')) {
                $table->dropColumn('trial_days');
            }
        });

        Schema::table('users', function (Blueprint $table) {
            if (Schema::hasColumn('users', 'profile_music_url')) {
                $table->dropColumn('profile_music_url');
            }
        });
    }
};
