<?php

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

use App\Models\StaffProfile;

return new class () extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('staff_profiles', function (Blueprint $table) {
            $table->mediumText('bio_draft')->nullable();
            $table->dateTime('published_at')->nullable();
        });

        foreach (StaffProfile::all() as $staff_profile) {
            $staff_profile->bio_draft = $staff_profile->bio;
            $staff_profile->save();
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('staff_profiles', function (Blueprint $table) {
            //
        });
    }
};
