54 lines
1.3 KiB
PHP
54 lines
1.3 KiB
PHP
|
<?php
|
||
|
|
||
|
use App\Models\Bookmark;
|
||
|
use App\Models\Tag;
|
||
|
use Illuminate\Database\Migrations\Migration;
|
||
|
use Illuminate\Database\Schema\Blueprint;
|
||
|
use Illuminate\Support\Facades\Schema;
|
||
|
|
||
|
return new class extends Migration
|
||
|
{
|
||
|
/**
|
||
|
* Run the migrations.
|
||
|
*/
|
||
|
public function up(): void
|
||
|
{
|
||
|
Schema::create(
|
||
|
'bookmarks', function (Blueprint $table) {
|
||
|
$table->id();
|
||
|
$table->string('href', 4096);
|
||
|
$table->string('title', 1024);
|
||
|
$table->text('description');
|
||
|
$table->timestamps();
|
||
|
}
|
||
|
);
|
||
|
|
||
|
Schema::create(
|
||
|
'tags', function (Blueprint $table) {
|
||
|
$table->id();
|
||
|
$table->string('name', 255)->unique();
|
||
|
$table->timestamps();
|
||
|
}
|
||
|
);
|
||
|
|
||
|
Schema::create(
|
||
|
'bookmark_tag', function (Blueprint $table) {
|
||
|
$table->foreignIdFor(Bookmark::class);
|
||
|
$table->foreignIdFor(Tag::class);
|
||
|
$table->primary(['bookmark_id', 'tag_id']);
|
||
|
$table->timestamps();
|
||
|
}
|
||
|
);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Reverse the migrations.
|
||
|
*/
|
||
|
public function down(): void
|
||
|
{
|
||
|
Schema::dropIfExists('bookmarks');
|
||
|
Schema::dropIfExists('tags');
|
||
|
Schema::dropIfExists('bookmark_tag');
|
||
|
}
|
||
|
};
|