2018_08_14_161949_create_courses_users_table.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreateCoursesUsersTable extends Migration
  6. {
  7. protected $table = 'courses_users';
  8. protected $tb_cors = 'courses';
  9. protected $tb_users = TABLE_USERS;
  10. /**
  11. * Run the migrations.
  12. *
  13. * @return void
  14. */
  15. public function up()
  16. {
  17. Schema::create($this->table, function (Blueprint $table) {
  18. $table->increments('id')->comment('唯一标识')->unsigned();
  19. $table->integer('cid')->comment('对应课程id')->unsigned();
  20. $table->integer('uid')->comment('对应会员id')->unsigned();
  21. $table->timestamps();
  22. $table->foreign('cid')->references('id')->on($this->tb_cors);
  23. $table->foreign('uid')->references('id')->on($this->tb_users);
  24. });
  25. DB::statement("ALTER TABLE ".$this->table." comment'课程报名信息表'");
  26. }
  27. /**
  28. * Reverse the migrations.
  29. *
  30. * @return void
  31. */
  32. public function down()
  33. {
  34. Schema::dropIfExists($this->table);
  35. }
  36. }