38 lines
		
	
	
		
			949 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
		
			949 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
use Illuminate\Database\Migrations\Migration;
 | 
						|
use Illuminate\Database\Schema\Blueprint;
 | 
						|
use Illuminate\Support\Facades\Schema;
 | 
						|
 | 
						|
class CreateLikesTable extends Migration
 | 
						|
{
 | 
						|
    /**
 | 
						|
     * Run the migrations.
 | 
						|
     *
 | 
						|
     * @return void
 | 
						|
     */
 | 
						|
    public function up()
 | 
						|
    {
 | 
						|
        Schema::create('likes', function (Blueprint $table) {
 | 
						|
            $table->increments('id');
 | 
						|
            $table->integer('user_id')->index();
 | 
						|
            $table->integer('ejaculation_id')->index();
 | 
						|
            $table->timestamps();
 | 
						|
 | 
						|
            $table->unique(['user_id', 'ejaculation_id']);
 | 
						|
            $table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
 | 
						|
            $table->foreign('ejaculation_id')->references('id')->on('ejaculations')->onDelete('cascade');
 | 
						|
        });
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * Reverse the migrations.
 | 
						|
     *
 | 
						|
     * @return void
 | 
						|
     */
 | 
						|
    public function down()
 | 
						|
    {
 | 
						|
        Schema::dropIfExists('likes');
 | 
						|
    }
 | 
						|
}
 |