No Description

2019_07_07_191614_create_sections_table.php 1.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreateSectionsTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('sections', function (Blueprint $table) {
  15. $table->bigIncrements('id');
  16. $table->char('semester_code', 3);
  17. $table->unsignedBigInteger('course_id');
  18. $table->char('code', 3);
  19. $table->unsignedInteger('student_count')->nullable();
  20. $table->string('syllabus')->nullable();
  21. $table->unsignedDecimal('credits')->nullable();
  22. $table->unsignedDecimal('quota')->nullable();
  23. $table->foreign('semester_code')->references('code')->on('semesters');
  24. $table->foreign('course_id')->references('id')->on('courses')->onUpdate('cascade');
  25. $table->unique(['semester_code', 'course_id', 'code']);
  26. });
  27. }
  28. /**
  29. * Reverse the migrations.
  30. *
  31. * @return void
  32. */
  33. public function down()
  34. {
  35. Schema::dropIfExists('sections');
  36. }
  37. }