add migration table

master
sundayenglish 4 weeks ago
parent 55c47d4842
commit 70eb021c6b
  1. 25
      database/migrations/2025_06_26_035409_create_se_subjects_table.php
  2. 25
      database/migrations/2025_06_26_035709_create_se_categories_table.php
  3. 24
      database/migrations/2025_06_26_035807_create_se_skills_table.php
  4. 25
      database/migrations/2025_06_26_035826_create_se_question_types_table.php
  5. 28
      database/migrations/2025_06_26_035908_create_se_media_table.php
  6. 34
      database/migrations/2025_06_26_035927_create_se_exercises_table.php
  7. 32
      database/migrations/2025_06_26_040018_create_se_question_groups_table.php
  8. 36
      database/migrations/2025_06_26_040033_create_se_questions_table.php
  9. 27
      database/migrations/2025_06_26_040054_create_se_exercise_questions_table.php
  10. 32
      database/migrations/2025_06_26_040122_create_se_question_choices_table.php
  11. 25
      database/migrations/2025_06_26_040136_create_se_question_blanks_table.php

@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('se_subjects', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('code')->unique();
$table->text('description')->nullable();
$table->integer('status')->default(1); // true = active, false = inactive
$table->timestamps();
$table->softDeletes(); // deleted_at
});
}
public function down(): void
{
Schema::dropIfExists('se_subjects');
}
};

@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('se_categories', function (Blueprint $table) {
$table->id();
$table->string('content');
$table->string('content_vi')->nullable();
$table->text('description')->nullable();
$table->integer('status')->default(1);
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('se_categories');
}
};

@ -0,0 +1,24 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('se_skills', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->string('code')->unique();
$table->text('description')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('se_skills');
}
};

@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('se_question_types', function (Blueprint $table) {
$table->id();
$table->string('name');
$table->text('description')->nullable();
$table->string('code')->unique();
$table->integer('status')->default(1);
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('se_question_types');
}
};

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('se_media', function (Blueprint $table) {
$table->id();
// Nếu muốn polymorphic, bạn nên thêm $table->string('object_type') để phân biệt loại object
$table->unsignedBigInteger('object_id');
$table->string('file_name');
$table->string('file_url');
$table->string('mime_type');
$table->unsignedBigInteger('size_bytes');
$table->integer('position')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('se_media');
}
};

@ -0,0 +1,34 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('se_exercises', function (Blueprint $table) {
$table->id();
// Chỉ giữ tên cột, không ràng buộc FK
$table->unsignedBigInteger('subject_id');
$table->string('lesson_name');
$table->text('description')->nullable();
$table->integer('level')->default(0);
$table->string('avatar')->nullable();
$table->integer('status')->default(1); // true = active, false = inactive
$table->unsignedBigInteger('category_id');
$table->unsignedBigInteger('skill_id');
$table->integer('year')->nullable();
$table->unsignedBigInteger('media_object_id')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('se_exercises');
}
};

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('se_question_groups', function (Blueprint $table) {
$table->id();
$table->text('content');
$table->text('content_vi')->nullable();
$table->unsignedBigInteger('exercise_id');
$table->integer('is_question_order_fixed')->default(0);
$table->integer('is_option_order_fixed')->default(0);
$table->integer('position')->default(0);
$table->text('paragraph')->nullable();
$table->unsignedBigInteger('media_object_id')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('se_question_groups');
}
};

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('se_questions', function (Blueprint $table) {
$table->id();
// Các cột FK giờ chỉ giữ tên, không còn ràng buộc
$table->unsignedBigInteger('exercise_id');
$table->text('content');
$table->text('description')->nullable();
$table->unsignedBigInteger('group_id')->nullable();
$table->unsignedBigInteger('question_type_id');
$table->integer('level')->default(0);
$table->integer('score')->default(1);
$table->text('answer')->nullable();
$table->text('explanation')->nullable();
$table->text('hint')->nullable();
$table->unsignedBigInteger('media_object_id')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('se_questions');
}
};

@ -0,0 +1,27 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('se_exercise_questions', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('exercise_id');
$table->unsignedBigInteger('question_id');
$table->integer('position')->default(0);
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('se_exercise_questions');
}
};

@ -0,0 +1,32 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('se_question_choices', function (Blueprint $table) {
$table->id();
// Chỉ giữ cột, không còn ràng buộc FK
$table->unsignedBigInteger('question_id');
$table->string('label')->nullable();
$table->text('content')->nullable();
$table->integer('is_correct')->default(0); // 0 = false, 1 = true
$table->json('media')->nullable();
$table->unsignedBigInteger('media_object_id')->nullable();
$table->integer('position')->default(0);
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('se_question_choices');
}
};

@ -0,0 +1,25 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration {
public function up(): void
{
Schema::create('se_question_blanks', function (Blueprint $table) {
$table->id();
$table->unsignedBigInteger('question_id');
$table->integer('position')->default(0);
$table->text('correct_answer');
$table->json('other_answers')->nullable();
$table->timestamps();
$table->softDeletes();
});
}
public function down(): void
{
Schema::dropIfExists('se_question_blanks');
}
};
Loading…
Cancel
Save