2022_05_29_103822_create_likes_table.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class CreateLikesTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. /*
  13. 点赞 like
  14. 关注 watch
  15. 收藏 favorite
  16. 书签 bookmark
  17. */
  18. public function up()
  19. {
  20. Schema::create('likes', function (Blueprint $table) {
  21. $table->uuid('id')->primary()->default(DB::raw('uuid_generate_v1mc()'));
  22. $table->string('type',32)->index();
  23. $table->uuid('target_id')->index();
  24. $table->string('target_type',32)->index();
  25. $table->string('context',128)->nullable();
  26. $table->uuid('user_id')->index();
  27. $table->timestamps();
  28. $table->unique(['type','target_id','user_id']);
  29. });
  30. }
  31. /**
  32. * Reverse the migrations.
  33. *
  34. * @return void
  35. */
  36. public function down()
  37. {
  38. Schema::dropIfExists('likes');
  39. }
  40. }