Tag blog posts and sign them with a member
Tags are named in every language and made from the page form; the byline is the member who signs a post on the site. The public API sends both, filters posts by tag and lists the tags in use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* For the blog: tags to group posts by subject, and a byline — the member who
|
||||
* signs a post, which is not always the account that typed it in.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('tags', function (Blueprint $table): void {
|
||||
$table->id();
|
||||
$table->jsonb('name');
|
||||
$table->jsonb('slug');
|
||||
$table->timestamps();
|
||||
});
|
||||
|
||||
Schema::create('page_tag', function (Blueprint $table): void {
|
||||
$table->foreignId('page_id')->constrained()->cascadeOnDelete();
|
||||
$table->foreignId('tag_id')->constrained()->cascadeOnDelete();
|
||||
$table->primary(['page_id', 'tag_id']);
|
||||
});
|
||||
|
||||
Schema::table('pages', function (Blueprint $table): void {
|
||||
$table->foreignId('byline_member_id')->nullable()->after('author_id')->constrained('members')->nullOnDelete();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('pages', function (Blueprint $table): void {
|
||||
$table->dropConstrainedForeignId('byline_member_id');
|
||||
});
|
||||
|
||||
Schema::dropIfExists('page_tag');
|
||||
Schema::dropIfExists('tags');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user