mirror of
https://github.com/brunofontes/shareit.git
synced 2024-11-23 20:10:52 +00:00
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.
This commit is contained in:
parent
ee9a01651d
commit
e2942224db
@ -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');
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class ItemUser extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::create('item_user', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->integer('item_id');
|
||||
$table->integer('user_id');
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('item_user');
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user