12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <?php
-
- use Illuminate\Support\Facades\Schema;
- use Illuminate\Database\Schema\Blueprint;
- use Illuminate\Database\Migrations\Migration;
-
- class CreateSectionsTable extends Migration
- {
- /**
- * Run the migrations.
- *
- * @return void
- */
- public function up()
- {
- Schema::create('sections', function (Blueprint $table) {
- $table->bigIncrements('id');
- $table->char('semester_code', 3);
- $table->unsignedBigInteger('course_id');
- $table->char('code', 3);
- $table->unsignedInteger('student_count')->nullable();
- $table->string('syllabus')->nullable();
- $table->unsignedDecimal('credits')->nullable();
- $table->unsignedDecimal('quota')->nullable();
-
-
- $table->foreign('semester_code')->references('code')->on('semesters');
- $table->foreign('course_id')->references('id')->on('courses')->onUpdate('cascade');
-
- $table->unique(['semester_code', 'course_id', 'code']);
- });
- }
-
- /**
- * Reverse the migrations.
- *
- * @return void
- */
- public function down()
- {
- Schema::dropIfExists('sections');
- }
- }
|