<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    public function up(): void
    {
        App\Support\SqliteCompat::statement(<<<'SQL'
CREATE TABLE `payment_error` (
`id` int UNSIGNED NOT NULL,
  `payment_id` int NOT NULL,
  `invoice_id` int NOT NULL,
  `parent_id` int NOT NULL,
  `wrong_paid_amount` decimal(10,2) NOT NULL,
  `wrong_payment_method` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
  `wrong_check_file` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `error_note` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `logged_at` datetime NOT NULL,
  `logged_by` int DEFAULT NULL,
  `school_year` varchar(20) COLLATE utf8mb4_general_ci DEFAULT NULL,
  `semester` varchar(10) COLLATE utf8mb4_general_ci DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
SQL
        );

        App\Support\SqliteCompat::statement(<<<'SQL'
ALTER TABLE `payment_error`
  ADD PRIMARY KEY (`id`);
SQL
        );

        App\Support\SqliteCompat::statement(<<<'SQL'
ALTER TABLE `payment_error`
  MODIFY `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT;
SQL
        );

    }

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