Brak opisu

2015_05_18_134926_add_semester_id_to_courses.php 756B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. class AddSemesterIdToCourses extends Migration {
  5. /**
  6. * Run the migrations.
  7. *
  8. * @return void
  9. */
  10. public function up()
  11. {
  12. Schema::table('courses', function(Blueprint $table)
  13. {
  14. $table->integer('semester_id')->unsigned()->default(1)->after('user_id');
  15. });
  16. Schema::table('courses', function(Blueprint $table)
  17. {
  18. $table->foreign('semester_id')->references('id')->on('semesters');
  19. });
  20. }
  21. /**
  22. * Reverse the migrations.
  23. *
  24. * @return void
  25. */
  26. public function down()
  27. {
  28. Schema::table('courses', function(Blueprint $table)
  29. {
  30. $table->dropForeign('courses_semester_id_foreign');
  31. $table->dropColumn('semester_id');
  32. });
  33. }
  34. }