No Description

2019_07_07_190000_create_courses_table.php 826B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreateCoursesTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('courses', function (Blueprint $table) {
  15. $table->bigIncrements('id');
  16. $table->char('code', 8)->unique();
  17. $table->string('title');
  18. $table->unsignedBigInteger('dept_id');
  19. $table->string('syllabus')->nullable();
  20. $table->foreign('dept_id')->references('id')->on('departments');
  21. });
  22. }
  23. /**
  24. * Reverse the migrations.
  25. *
  26. * @return void
  27. */
  28. public function down()
  29. {
  30. Schema::dropIfExists('courses');
  31. }
  32. }