<?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::create('social_accounts', function (Blueprint $table) {
            $table->id();

            $table
                ->foreignId('brand_id')
                ->constrained()
                ->cascadeOnDelete();

            $table->string('provider');
            $table->string('account_name');
            $table->string('account_id')->nullable();

            $table->string('username')->nullable();
            $table->string('profile_picture')->nullable();

            $table->longText('access_token')->nullable();
            $table->longText('refresh_token')->nullable();

            $table->timestamp('token_expires_at')->nullable();

            $table->enum('status', [
                'active',
                'inactive'
            ])->default('active');

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('social_accounts');
    }
};
