<?php

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

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('scorm_sco_tracking', function (Blueprint $table) {
            $table->renameColumn('exit_mode', 'exit');
            $table->renameColumn('lesson_location', 'location');
            $table->renameColumn('lesson_mode', 'mode');
            $table->string('session_time')->change();
        });

        Schema::table('scorm', function (Blueprint $table) {
            $table->unique('uuid');
        });

        Schema::table('scorm_sco', function (Blueprint $table) {
            $table->unique('uuid');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::table('scorm_sco_tracking', function (Blueprint $table) {
            $table->renameColumn('exit', 'exit_mode');
            $table->renameColumn('location', 'lesson_location');
            $table->renameColumn('mode', 'lesson_mode');
        });

        Schema::table('scorm', function (Blueprint $table) {
            $table->dropUnique('scorm_uuid_unique');
        });

        Schema::table('scorm_sco', function (Blueprint $table) {
            $table->dropUnique('scorm_sco_uuid_unique');
        });
    }
};