17 lines
672 B
PHP
17 lines
672 B
PHP
<?php
|
|||
|
|
use Illuminate\Database\Migrations\Migration;
|
||
|
|
use Illuminate\Database\Schema\Blueprint;
|
||
|
|
use Illuminate\Support\Facades\Schema;
|
||
|
|
return new class extends Migration {
|
||
|
|
public function up(): void {
|
||
|
|
Schema::create('follows', function (Blueprint $table) {
|
||
|
|
$table->foreignId('follower_id')->constrained('users')->cascadeOnDelete();
|
||
|
|
$table->foreignId('following_id')->constrained('users')->cascadeOnDelete();
|
||
|
|
$table->primary(['follower_id', 'following_id']);
|
||
|
|
$table->index('following_id');
|
||
|
|
$table->timestamps();
|
||
|
|
});
|
||
|
|
}
|
||
|
|
public function down(): void { Schema::dropIfExists('follows'); }
|
||
|
|
};
|