2018_04_23_105524_create_actives_users_table.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class CreateActivesUsersTable extends Migration
  6. {
  7. protected $table = 'actives_users';
  8. protected $tb_acts = 'actives';
  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('aid')->comment('对应活动id')->unsigned();
  20. $table->integer('uid')->comment('对应会员id')->unsigned();
  21. $table->tinyInteger('score')->comment('分数')->unsigned()->nullable();
  22. $table->timestamps();
  23. $table->foreign('aid')->references('id')->on($this->tb_acts);
  24. $table->foreign('uid')->references('id')->on($this->tb_users);
  25. });
  26. DB::statement("ALTER TABLE ".$this->table." comment'活动信息表'");
  27. }
  28. /**
  29. * Reverse the migrations.
  30. *
  31. * @return void
  32. */
  33. public function down()
  34. {
  35. Schema::dropIfExists($this->table);
  36. }
  37. }