38 lines
1.0 KiB
PHP
Executable File
38 lines
1.0 KiB
PHP
Executable File
<?php
|
|
|
|
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('insights', function (Blueprint $table) {
|
|
$table->id();
|
|
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
|
$table->foreignId('subject_id')->constrained()->cascadeOnDelete();
|
|
$table->text('content');
|
|
$table->string('type')->default('insight');
|
|
$table->json('metadata')->nullable();
|
|
$table->integer('input_tokens')->default(0);
|
|
$table->integer('output_tokens')->default(0);
|
|
$table->timestamp('sent_at')->nullable();
|
|
$table->timestamps();
|
|
|
|
$table->index(['user_id', 'subject_id', 'created_at']);
|
|
});
|
|
}
|
|
|
|
/**
|
|
* Reverse the migrations.
|
|
*/
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('insights');
|
|
}
|
|
};
|