2019_12_25_042317_update_stories_table.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. public function __construct()
  8. {
  9. DB::getDoctrineSchemaManager()->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
  10. }
  11. /**
  12. * Run the migrations.
  13. *
  14. * @return void
  15. */
  16. public function up()
  17. {
  18. Schema::dropIfExists('stories');
  19. Schema::dropIfExists('story_items');
  20. Schema::dropIfExists('story_reactions');
  21. Schema::dropIfExists('story_views');
  22. Schema::create('stories', function (Blueprint $table) {
  23. $table->bigIncrements('id');
  24. $table->bigInteger('profile_id')->unsigned()->index();
  25. $table->string('type')->nullable();
  26. $table->unsignedInteger('size')->nullable();
  27. $table->string('mime')->nullable();
  28. $table->smallInteger('duration')->unsigned();
  29. $table->string('path')->nullable();
  30. $table->string('cdn_url')->nullable();
  31. $table->boolean('public')->default(false)->index();
  32. $table->boolean('local')->default(false)->index();
  33. $table->unsignedInteger('view_count')->nullable();
  34. $table->unsignedInteger('comment_count')->nullable();
  35. $table->json('story')->nullable();
  36. $table->unique(['profile_id', 'path']);
  37. $table->timestamp('expires_at')->index();
  38. $table->timestamps();
  39. });
  40. Schema::create('story_views', function (Blueprint $table) {
  41. $table->bigIncrements('id');
  42. $table->bigInteger('story_id')->unsigned()->index();
  43. $table->bigInteger('profile_id')->unsigned()->index();
  44. $table->unique(['profile_id', 'story_id']);
  45. $table->timestamps();
  46. });
  47. }
  48. /**
  49. * Reverse the migrations.
  50. *
  51. * @return void
  52. */
  53. public function down()
  54. {
  55. Schema::dropIfExists('stories');
  56. Schema::dropIfExists('story_views');
  57. }
  58. }