Skip to content

Commit 3eec9c5

Browse files
committed
add favorites table migration
1 parent 6cb9090 commit 3eec9c5

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
use Illuminate\Database\Migrations\Migration;
4+
use Illuminate\Database\Schema\Blueprint;
5+
use Illuminate\Support\Facades\Schema;
6+
7+
return new class extends Migration
8+
{
9+
/**
10+
* Run the migrations.
11+
*/
12+
public function up(): void
13+
{
14+
Schema::create('favorites', function (Blueprint $table) {
15+
$table->id();
16+
$table->unsignedBigInteger("user_id");
17+
$table->unsignedBigInteger("post_id");
18+
$table->timestamps();
19+
20+
$table->foreign("user_id")->references("id")->on("users")->cascadeOnDelete()->cascadeOnUpdate();
21+
$table->foreign("post_id")->references("id")->on("posts")->cascadeOnDelete()->cascadeOnUpdate();
22+
});
23+
}
24+
25+
/**
26+
* Reverse the migrations.
27+
*/
28+
public function down(): void
29+
{
30+
Schema::dropIfExists('favorites');
31+
}
32+
};

0 commit comments

Comments
 (0)