<?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 `paypal_transactions` (
`id` int NOT NULL,
  `transaction_id` varchar(100) NOT NULL,
  `payment_id` int DEFAULT NULL,
  `firstname` varchar(100) DEFAULT NULL,
  `lastname` varchar(100) DEFAULT NULL,
  `event_type` varchar(100) NOT NULL,
  `payer_email` varchar(255) DEFAULT NULL,
  `amount` decimal(10,2) NOT NULL DEFAULT '0.00',
  `currency` varchar(10) NOT NULL,
  `status` varchar(50) NOT NULL DEFAULT 'Pending',
  `payment_method` varchar(50) NOT NULL,
  `transaction_fee` decimal(10,2) NOT NULL DEFAULT '0.00',
  `raw_data` text,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `school_year` varchar(20) DEFAULT NULL,
  `semester` varchar(10) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `permissions`
--


CREATE TABLE `permissions` (

`id` int UNSIGNED NOT NULL,

  `name` varchar(255) NOT NULL,

  `description` text,

  `created_at` datetime DEFAULT NULL,

  `updated_at` datetime DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3;

-- --------------------------------------------------------

--
-- Table structure for table `placement_batches`
--


CREATE TABLE `placement_batches` (

`id` int UNSIGNED NOT NULL,

  `placement_test` varchar(30) COLLATE utf8mb4_unicode_ci NOT NULL,

  `school_year` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL,

  `created_by` int UNSIGNED DEFAULT NULL,

  `updated_by` int UNSIGNED DEFAULT NULL,

  `created_at` datetime DEFAULT NULL,

  `updated_at` datetime DEFAULT NULL

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
SQL
        );

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

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

    }

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