2020_08_21_145711_create_invite_table.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class CreateInviteTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('invite', function (Blueprint $table) {
  15. $table->increments('id');
  16. $table->unsignedInteger('inviter_id')->default(0)->comment('邀请ID');
  17. $table->unsignedInteger('invitee_id')->nullable()->comment('受邀ID');
  18. $table->char('code', 12)->unique()->comment('邀请码');
  19. $table->boolean('status')->default(0)->comment('邀请码状态:0-未使用、1-已使用、2-已过期');
  20. $table->dateTime('dateline')->comment('有效期至');
  21. $table->dateTime('created_at')->comment('创建时间');
  22. $table->dateTime('updated_at')->comment('最后更新时间');
  23. $table->softDeletes()->comment('删除时间');
  24. });
  25. }
  26. /**
  27. * Reverse the migrations.
  28. *
  29. * @return void
  30. */
  31. public function down()
  32. {
  33. Schema::dropIfExists('invite');
  34. }
  35. }