PromptVault/database/migrations/2026_10_24_000002_create_prompts_table.php

35 lines
1.1 KiB
PHP
Raw Normal View History

2026-10-26 20:12:16 +00:00
<?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('prompts', function (Blueprint $table) {
$table->id();
$table->string('name', 120);
$table->string('description', 500)->nullable();
$table->text('body');
$table->boolean('is_favorite')->default(false);
$table->unsignedInteger('usage_count')->default(0);
$table->timestamp('last_used_at')->nullable();
$table->timestamps();
});
Schema::create('prompt_tag', function (Blueprint $table) {
$table->foreignId('prompt_id')->constrained('prompts')->cascadeOnDelete();
$table->foreignId('tag_id')->constrained('tags')->cascadeOnDelete();
$table->primary(['prompt_id', 'tag_id']);
});
}
public function down(): void
{
Schema::dropIfExists('prompt_tag');
Schema::dropIfExists('prompts');
}
};