Bez popisu

2014_10_07_020335_create_professors_table.php 916B

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