<?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::create('artwork_shares', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('artwork_id');
            $table->unsignedBigInteger('user_id')->nullable();
            $table->string('platform', 32); // facebook, twitter, pinterest, copy, email, embed
            $table->timestamp('created_at')->useCurrent();

            $table->index('artwork_id');
            $table->index('platform');
            $table->index(['artwork_id', 'platform']);
        });
    }

    public function down(): void
    {
        Schema::dropIfExists('artwork_shares');
    }
};
