<?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_social_links', function (Blueprint $table) {
            $table->enum('visibility', ['public', 'registered', 'subscribers', 'only_me'])
                  ->default('public')
                  ->after('value');
        });

        // Default sensitive platforms to 'subscribers'
        \DB::table('user_social_links')
            ->whereIn('platform', ['whatsapp', 'social_phone', 'social_email'])
            ->update(['visibility' => 'subscribers']);
    }

    public function down(): void
    {
        Schema::table('user_social_links', function (Blueprint $table) {
            $table->dropColumn('visibility');
        });
    }
};
