current state
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
Schema::create('user_favorites', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
|
||||
$table->unsignedBigInteger('user_id');
|
||||
$table->unsignedBigInteger('artwork_id');
|
||||
|
||||
$table->timestamp('created_at')->useCurrent();
|
||||
|
||||
$table->unique(['user_id', 'artwork_id'], 'uniq_user_artwork');
|
||||
$table->index('artwork_id', 'idx_artwork');
|
||||
$table->index(['user_id', 'created_at'], 'idx_user_created');
|
||||
|
||||
$table->foreign('user_id')->references('id')->on('users')->onDelete('cascade');
|
||||
$table->foreign('artwork_id')->references('id')->on('artworks')->onDelete('cascade');
|
||||
});
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('user_favorites');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user