<?php

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

/**
 * Lets staff attach the scanned, owner-signed copy of a consent back onto the
 * consent record after it has been printed and signed.
 */
class AddSignedFileToClcConsents extends Migration
{
    public function up()
    {
        Schema::table('clc_consents', function (Blueprint $table) {
            $table->string('signed_file_path')->nullable()->after('notes');
            $table->string('signed_file_name')->nullable()->after('signed_file_path');
            $table->unsignedInteger('signed_file_size')->nullable()->after('signed_file_name');
            $table->string('signed_mime_type', 100)->nullable()->after('signed_file_size');
            $table->timestamp('signed_uploaded_at')->nullable()->after('signed_mime_type');
            $table->unsignedInteger('signed_uploaded_by')->nullable()->after('signed_uploaded_at');
        });
    }

    public function down()
    {
        Schema::table('clc_consents', function (Blueprint $table) {
            $table->dropColumn([
                'signed_file_path', 'signed_file_name', 'signed_file_size',
                'signed_mime_type', 'signed_uploaded_at', 'signed_uploaded_by',
            ]);
        });
    }
}
