survey-sdgs/database/migrations/2024_05_15_112823_add_answe...

31 lines
754 B
PHP
Executable File

<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
// Add answer_id to make unique answer per question
Schema::table('question_answers', function (Blueprint $table) {
$table->unsignedBigInteger('answer_id')->after('survey_id'); // answer_id
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
// remove answer_id
Schema::table('question_answers', function (Blueprint $table) {
$table->dropColumn('answer_id'); // answer_id
});
}
};