暫無描述

2014_11_29_211309_create_courses_table.php 918B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. use Illuminate\Database\Schema\Blueprint;
  3. use Illuminate\Database\Migrations\Migration;
  4. class CreateCoursesTable extends Migration {
  5. /**
  6. * Run the migrations.
  7. *
  8. * @return void
  9. */
  10. public function up()
  11. {
  12. Schema::create('courses', function(Blueprint $table)
  13. {
  14. $table->increments('id');
  15. $table->string('name');
  16. $table->char('code', 8);
  17. $table->char('section', 3);
  18. $table->integer('program_id')->unsigned();
  19. $table->integer('user_id')->unsigned();
  20. $table->timestamps();
  21. });
  22. Schema::table('courses', function(Blueprint $table)
  23. {
  24. $table->foreign('program_id')->references('id')->on('programs')->onDelete('cascade')->onUpdate('cascade');
  25. $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade')->onUpdate('cascade');
  26. });
  27. }
  28. /**
  29. * Reverse the migrations.
  30. *
  31. * @return void
  32. */
  33. public function down()
  34. {
  35. Schema::drop('courses');
  36. }
  37. }