<?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('users', function (Blueprint $table) {
            $table->string('churchtools_id')->nullable()->unique()->after('email');
            $table->string('avatar')->nullable()->after('password');
            $table->json('churchtools_groups')->nullable()->after('avatar');
            $table->json('churchtools_roles')->nullable()->after('churchtools_groups');
        });
    }

    public function down(): void
    {
        Schema::table('users', function (Blueprint $table) {
            $table->dropUnique('users_churchtools_id_unique');
            $table->dropColumn([
                'churchtools_id',
                'avatar',
                'churchtools_groups',
                'churchtools_roles',
            ]);
        });
    }
};
