From e2942224dbae54825ed1440afd562bba3828957f Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Fri, 14 Sep 2018 17:24:26 -0300 Subject: [PATCH] Refactoring item_user migration Delete the separate value for item_user, adding a primary key to the pivot table and removing the timestamp as it is not necessary. --- .../2018_09_08_192152_create_items_table.php | 8 +++++ .../2018_09_10_233609_item_user.php | 33 ------------------- 2 files changed, 8 insertions(+), 33 deletions(-) delete mode 100644 database/migrations/2018_09_10_233609_item_user.php diff --git a/database/migrations/2018_09_08_192152_create_items_table.php b/database/migrations/2018_09_08_192152_create_items_table.php index 294d932..d1b83e3 100644 --- a/database/migrations/2018_09_08_192152_create_items_table.php +++ b/database/migrations/2018_09_08_192152_create_items_table.php @@ -21,6 +21,13 @@ class CreateItemsTable extends Migration $table->integer('waiting_user_id')->nullable(); $table->timestamps(); }); + + Schema::create('item_user', function (Blueprint $table) { + $table->increments('id'); + $table->integer('item_id'); + $table->integer('user_id'); + $table->primary(['item_id', 'user_id']); + }); } /** @@ -31,5 +38,6 @@ class CreateItemsTable extends Migration public function down() { Schema::dropIfExists('items'); + Schema::dropIfExists('item_user'); } } diff --git a/database/migrations/2018_09_10_233609_item_user.php b/database/migrations/2018_09_10_233609_item_user.php deleted file mode 100644 index 3308188..0000000 --- a/database/migrations/2018_09_10_233609_item_user.php +++ /dev/null @@ -1,33 +0,0 @@ -increments('id'); - $table->integer('item_id'); - $table->integer('user_id'); - $table->timestamps(); - }); - } - - /** - * Reverse the migrations. - * - * @return void - */ - public function down() - { - Schema::dropIfExists('item_user'); - } -}