<?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('watermark_settings', function (Blueprint $table) {
            if (! Schema::hasColumn('watermark_settings', 'offset_x')) {
                $table->integer('offset_x')->default(0)->after('padding');
            }
            if (! Schema::hasColumn('watermark_settings', 'offset_y')) {
                $table->integer('offset_y')->default(0)->after('offset_x');
            }
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::table('watermark_settings', function (Blueprint $table) {
            if (Schema::hasColumn('watermark_settings', 'offset_y')) {
                $table->dropColumn('offset_y');
            }
            if (Schema::hasColumn('watermark_settings', 'offset_x')) {
                $table->dropColumn('offset_x');
            }
        });
    }
};
