diff --git a/database/migrations/2025_06_26_035409_create_se_subjects_table.php b/database/migrations/2025_06_26_035409_create_se_subjects_table.php new file mode 100644 index 0000000..fa716e2 --- /dev/null +++ b/database/migrations/2025_06_26_035409_create_se_subjects_table.php @@ -0,0 +1,25 @@ +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'); + } +}; diff --git a/database/migrations/2025_06_26_035709_create_se_categories_table.php b/database/migrations/2025_06_26_035709_create_se_categories_table.php new file mode 100644 index 0000000..3fb55f8 --- /dev/null +++ b/database/migrations/2025_06_26_035709_create_se_categories_table.php @@ -0,0 +1,25 @@ +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'); + } +}; diff --git a/database/migrations/2025_06_26_035807_create_se_skills_table.php b/database/migrations/2025_06_26_035807_create_se_skills_table.php new file mode 100644 index 0000000..88942c7 --- /dev/null +++ b/database/migrations/2025_06_26_035807_create_se_skills_table.php @@ -0,0 +1,24 @@ +id(); + $table->string('name'); + $table->string('code')->unique(); + $table->text('description')->nullable(); + $table->timestamps(); + $table->softDeletes(); + }); + } + + public function down(): void + { + Schema::dropIfExists('se_skills'); + } +}; diff --git a/database/migrations/2025_06_26_035826_create_se_question_types_table.php b/database/migrations/2025_06_26_035826_create_se_question_types_table.php new file mode 100644 index 0000000..fdba41c --- /dev/null +++ b/database/migrations/2025_06_26_035826_create_se_question_types_table.php @@ -0,0 +1,25 @@ +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'); + } +}; diff --git a/database/migrations/2025_06_26_035908_create_se_media_table.php b/database/migrations/2025_06_26_035908_create_se_media_table.php new file mode 100644 index 0000000..e46818b --- /dev/null +++ b/database/migrations/2025_06_26_035908_create_se_media_table.php @@ -0,0 +1,28 @@ +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'); + } +}; diff --git a/database/migrations/2025_06_26_035927_create_se_exercises_table.php b/database/migrations/2025_06_26_035927_create_se_exercises_table.php new file mode 100644 index 0000000..2f2f41c --- /dev/null +++ b/database/migrations/2025_06_26_035927_create_se_exercises_table.php @@ -0,0 +1,34 @@ +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'); + } +}; diff --git a/database/migrations/2025_06_26_040018_create_se_question_groups_table.php b/database/migrations/2025_06_26_040018_create_se_question_groups_table.php new file mode 100644 index 0000000..3ce0c73 --- /dev/null +++ b/database/migrations/2025_06_26_040018_create_se_question_groups_table.php @@ -0,0 +1,32 @@ +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'); + } +}; diff --git a/database/migrations/2025_06_26_040033_create_se_questions_table.php b/database/migrations/2025_06_26_040033_create_se_questions_table.php new file mode 100644 index 0000000..56f010c --- /dev/null +++ b/database/migrations/2025_06_26_040033_create_se_questions_table.php @@ -0,0 +1,36 @@ +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'); + } +}; diff --git a/database/migrations/2025_06_26_040054_create_se_exercise_questions_table.php b/database/migrations/2025_06_26_040054_create_se_exercise_questions_table.php new file mode 100644 index 0000000..50bc017 --- /dev/null +++ b/database/migrations/2025_06_26_040054_create_se_exercise_questions_table.php @@ -0,0 +1,27 @@ +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'); + } +}; diff --git a/database/migrations/2025_06_26_040122_create_se_question_choices_table.php b/database/migrations/2025_06_26_040122_create_se_question_choices_table.php new file mode 100644 index 0000000..7bb6b4f --- /dev/null +++ b/database/migrations/2025_06_26_040122_create_se_question_choices_table.php @@ -0,0 +1,32 @@ +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'); + } +}; diff --git a/database/migrations/2025_06_26_040136_create_se_question_blanks_table.php b/database/migrations/2025_06_26_040136_create_se_question_blanks_table.php new file mode 100644 index 0000000..4597d79 --- /dev/null +++ b/database/migrations/2025_06_26_040136_create_se_question_blanks_table.php @@ -0,0 +1,25 @@ +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'); + } +};