Без опису

2014_11_30_134022_create_students_table.php 795B

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