<?php

use App\Models\PrefixSubtenants;
use Carbon\Carbon;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class SubtenancyMetadata extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // Extend report_organisation_attributes table
        Schema::table('prefix_subtenants', function (Blueprint $table) {
            $table->timestamps();
            $table->softDeletes();
        });

        PrefixSubtenants::whereNull('created_at')->update(['created_at' => Carbon::now(), 'updated_at' => Carbon::now()->subDays(20)]);
    }

    public function down() {
        Schema::table('prefix_subtenants', function (Blueprint $table) {
            $table->dropColumn('created_at');
            $table->dropColumn('updated_at');
            $table->dropColumn('deleted_at');
        });
    }
}
