urlsnail/database/migrations/2024_05_30_090816_create_urlsnail_tables.php

54 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2024-05-30 09:28:38 +00:00
<?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');
}
};