2019_12_25_042317_update_stories_table.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <?php
  2. use Illuminate\Database\Migrations\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Support\Facades\Schema;
  5. class UpdateStoriesTable extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::dropIfExists('stories');
  15. Schema::dropIfExists('story_items');
  16. Schema::dropIfExists('story_reactions');
  17. Schema::dropIfExists('story_views');
  18. Schema::create('stories', function (Blueprint $table) {
  19. $table->bigIncrements('id');
  20. $table->bigInteger('profile_id')->unsigned()->index();
  21. $table->string('type')->nullable();
  22. $table->unsignedInteger('size')->nullable();
  23. $table->string('mime')->nullable();
  24. $table->smallInteger('duration')->unsigned();
  25. $table->string('path')->nullable();
  26. $table->string('cdn_url')->nullable();
  27. $table->boolean('public')->default(false)->index();
  28. $table->boolean('local')->default(false)->index();
  29. $table->unsignedInteger('view_count')->nullable();
  30. $table->unsignedInteger('comment_count')->nullable();
  31. $table->json('story')->nullable();
  32. $table->unique(['profile_id', 'path']);
  33. $table->timestamp('expires_at')->index();
  34. $table->timestamps();
  35. });
  36. Schema::create('story_views', function (Blueprint $table) {
  37. $table->bigIncrements('id');
  38. $table->bigInteger('story_id')->unsigned()->index();
  39. $table->bigInteger('profile_id')->unsigned()->index();
  40. $table->unique(['profile_id', 'story_id']);
  41. $table->timestamps();
  42. });
  43. }
  44. /**
  45. * Reverse the migrations.
  46. *
  47. * @return void
  48. */
  49. public function down()
  50. {
  51. Schema::dropIfExists('stories');
  52. Schema::dropIfExists('story_views');
  53. }
  54. }