<?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('device_tokens', function (Blueprint $table) {
            $table->string('device_name', 120)->nullable();
        });

        Schema::table('transactions', function (Blueprint $table) {
            $table->unique(['organization_id', 'provider_reference'], 'transaction_provider_reference_unique');
        });

        Schema::table('patients', function (Blueprint $table) {
            $table->unique('user_id', 'patient_user_unique');
        });
    }

    public function down(): void
    {
        Schema::table('patients', function (Blueprint $table) {
            $table->dropUnique('patient_user_unique');
        });

        Schema::table('transactions', function (Blueprint $table) {
            $table->dropUnique('transaction_provider_reference_unique');
        });

        Schema::table('device_tokens', function (Blueprint $table) {
            $table->dropColumn('device_name');
        });
    }
};
