Aucune description

2019_07_07_191614_create_sections_table.php 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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->foreign('semester_code')->references('code')->on('semesters');
  23. $table->foreign('course_id')->references('id')->on('courses');
  24. $table->unique(['semester_code', 'course_id', 'code']);
  25. });
  26. }
  27. /**
  28. * Reverse the migrations.
  29. *
  30. * @return void
  31. */
  32. public function down()
  33. {
  34. Schema::dropIfExists('sections');
  35. }
  36. }