2022_02_04_012828_create_shares_table.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class CreateSharesTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('shares', function (Blueprint $table) {
  15. #使用雪花id
  16. $table->bigInteger('id')->primary();
  17. $table->string('res_id',36);
  18. $table->integer('res_type');
  19. $table->string('cooperator_id',36);
  20. $table->integer('cooperator_type');
  21. $table->integer('power');
  22. $table->bigInteger('create_time');
  23. $table->bigInteger('modify_time');
  24. $table->timestamp('accepted_at')->nullable()->index();
  25. $table->bigInteger('acceptor')->nullable();
  26. $table->timestamp('created_at')->useCurrent()->index();
  27. $table->timestamp('updated_at')->useCurrent()->useCurrentOnUpdate()->index();
  28. $table->unique(['res_id','res_type','cooperator_id','cooperator_type']);
  29. });
  30. }
  31. /**
  32. * Reverse the migrations.
  33. *
  34. * @return void
  35. */
  36. public function down()
  37. {
  38. Schema::dropIfExists('shares');
  39. }
  40. }