2019_01_12_054413_stories.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. use Illuminate\Support\Facades\Schema;
  3. use Illuminate\Database\Schema\Blueprint;
  4. use Illuminate\Database\Migrations\Migration;
  5. class Stories extends Migration
  6. {
  7. /**
  8. * Run the migrations.
  9. *
  10. * @return void
  11. */
  12. public function up()
  13. {
  14. Schema::create('story_items', function (Blueprint $table) {
  15. $table->bigIncrements('id');
  16. $table->bigInteger('story_id')->unsigned()->index();
  17. $table->string('media_path')->nullable();
  18. $table->string('media_url')->nullable();
  19. $table->tinyInteger('duration')->unsigned();
  20. $table->string('filter')->nullable();
  21. $table->string('link_url')->nullable()->index();
  22. $table->string('link_text')->nullable();
  23. $table->tinyInteger('order')->unsigned()->nullable();
  24. $table->string('type')->default('photo');
  25. $table->json('layers')->nullable();
  26. $table->timestamp('expires_at')->nullable();
  27. $table->timestamps();
  28. });
  29. Schema::create('story_views', function (Blueprint $table) {
  30. $table->bigIncrements('id');
  31. $table->bigInteger('story_id')->unsigned()->index();
  32. $table->bigInteger('profile_id')->unsigned()->index();
  33. $table->unique(['story_id', 'profile_id']);
  34. $table->timestamps();
  35. });
  36. Schema::table('stories', function (Blueprint $table) {
  37. $table->string('title')->nullable()->after('profile_id');
  38. $table->boolean('preview_photo')->default(false)->after('title');
  39. $table->boolean('local_only')->default(false)->after('preview_photo');
  40. $table->boolean('is_live')->default(false)->after('local_only');
  41. $table->string('broadcast_url')->nullable()->after('is_live');
  42. $table->string('broadcast_key')->nullable()->after('broadcast_url');
  43. });
  44. Schema::table('story_reactions', function (Blueprint $table) {
  45. $table->bigInteger('story_id')->unsigned()->index()->after('profile_id');
  46. });
  47. }
  48. /**
  49. * Reverse the migrations.
  50. *
  51. * @return void
  52. */
  53. public function down()
  54. {
  55. Schema::dropIfExists('story_items');
  56. Schema::dropIfExists('story_views');
  57. Schema::table('stories', function (Blueprint $table) {
  58. $table->dropColumn(['title','preview_photo','local_only','is_live','broadcast_url','broadcast_key']);
  59. });
  60. Schema::table('story_reactions', function (Blueprint $table) {
  61. $table->dropColumn('story_id');
  62. });
  63. }
  64. }