<?php

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

class ReportPreferences2 extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('report_organisation_attributes', function (Blueprint $table) {
            $table->tinyInteger('watermark')->nullable();
        });

        Schema::create('email_organisation_attributes', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->softDeletes();

            $table->string('email');

            $table->foreignId('organisation_id')->cascadeOnDelete()->nullable()->constrained('organisations');
        });

        Schema::create('report_links', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->softDeletes();

            $table->string('token');

            $table->enum('type', ['disposable', 'reusable', 'other_1', 'other_2', 'other_3', 'other_4']);

            $table->ipAddress('address')->nullable();

            $table->foreignId('report_id')->cascadeOnDelete()->constrained('pending_reports');
        });

    
    }

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