<?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::create('job_offers', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('account_id');
            $table->string('title', 255);
            $table->string('subtitle', 255 )->nullable();
            $table->text('content')->nullable();
            $table->unsignedBigInteger('country_id')->nullable();
            $table->date('active_until')->nullable();
            $table->string('contact_person', 150)->nullable();
            $table->string('contact_email', 255)->nullable();
            $table->boolean('contact_by_email');
            $table->boolean('contact_by_letter');
            $table->string('contact_url', 255)->nullable();
            $table->string('contact_name', 255)->nullable();
            $table->string('contact_address', 255)->nullable();
            $table->string('contact_postal_code', 10)->nullable();
            $table->string('contact_city', 100)->nullable();
            $table->string('status', 10)->nullable();
            $table->timestamps();

            $table->foreign('account_id')->references('id')
                ->on('accounts')->onDelete('CASCADE')->onUpdate('CASCADE');

            $table->foreign('country_id')->references('id')
                ->on('countries')->onDelete('SET NULL')->onUpdate('CASCADE');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('job_offers');
    }
};
