35 lines
1.1 KiB
PHP
35 lines
1.1 KiB
PHP
|
|
<?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');
|
||
|
|
}
|
||
|
|
};
|