mirror of
				https://github.com/brunofontes/shareit.git
				synced 2025-11-04 03:31:02 -03:00 
			
		
		
		
	Delete the separate value for item_user, adding a primary key to the pivot table and removing the timestamp as it is not necessary.
		
			
				
	
	
		
			44 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
use Illuminate\Support\Facades\Schema;
 | 
						|
use Illuminate\Database\Schema\Blueprint;
 | 
						|
use Illuminate\Database\Migrations\Migration;
 | 
						|
 | 
						|
class CreateItemsTable extends Migration
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * Run the migrations.
 | 
						|
     *
 | 
						|
     * @return void
 | 
						|
     */
 | 
						|
    public function up()
 | 
						|
    {
 | 
						|
        Schema::create('items', function (Blueprint $table) {
 | 
						|
            $table->increments('id');
 | 
						|
            $table->string('name');
 | 
						|
            $table->integer('product_id');
 | 
						|
            $table->integer('used_by')->nullable();
 | 
						|
            $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']);
 | 
						|
        });
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Reverse the migrations.
 | 
						|
     *
 | 
						|
     * @return void
 | 
						|
     */
 | 
						|
    public function down()
 | 
						|
    {
 | 
						|
        Schema::dropIfExists('items');
 | 
						|
        Schema::dropIfExists('item_user');
 | 
						|
    }
 | 
						|
}
 |