<?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('netmails',function (Blueprint $table) {
			$table->bigInteger('sent_id')->nullable()->after('sent_pkt');
			$table->foreign('sent_id')->references('id')->on('addresses');
		});

		Schema::table('netmail_path',function (Blueprint $table) {
			$table->string('recv_pkt')->nullable();
			$table->bigInteger('recv_id')->nullable()->after('recv_pkt');
			$table->foreign('recv_id')->references('id')->on('addresses');
		});

		DB::statement('ALTER TABLE echomail_seenby RENAME COLUMN packet TO sent_pkt');

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

		Schema::table('echomail_path',function (Blueprint $table) {
			$table->string('recv_pkt')->nullable();
		});
	}

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        abort(500,'Cant go back');
    }
};