You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
786 B

  1. <?php
  2. use Movim\Migration;
  3. use Illuminate\Database\Schema\Blueprint;
  4. class CreatePostUserViewsTable extends Migration
  5. {
  6. public function up()
  7. {
  8. $this->schema->create('post_user_views', function (Blueprint $table) {
  9. $table->string('user_id', 256);
  10. $table->integer('post_id')->unsigned();
  11. $table->foreign('user_id')
  12. ->references('id')->on('users')
  13. ->onDelete('cascade');
  14. $table->foreign('post_id')
  15. ->references('id')->on('posts')
  16. ->onDelete('cascade');
  17. $table->timestamps();
  18. $table->unique(['user_id', 'post_id']);
  19. });
  20. }
  21. public function down()
  22. {
  23. $this->schema->drop('post_user_views');
  24. }
  25. }