Migrate to laravel ai sdk (#181)
Also * upgrade to livewire 4 * replace rappsoft tables with filament
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Laravel\Ai\Migrations\AiMigration;
|
||||
|
||||
return new class extends AiMigration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('agent_conversations', function (Blueprint $table) {
|
||||
$table->string('id', 36)->primary();
|
||||
$table->foreignIdFor(User::class, 'user_id')->constrained()->onDelete('cascade')->nullable();
|
||||
$table->string('title');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['user_id', 'updated_at']);
|
||||
});
|
||||
|
||||
Schema::create('agent_conversation_messages', function (Blueprint $table) {
|
||||
$table->string('id', 36)->primary();
|
||||
$table->string('conversation_id', 36)->index();
|
||||
$table->foreignIdFor(User::class, 'user_id')->constrained()->onDelete('cascade')->nullable();
|
||||
$table->string('agent');
|
||||
$table->string('role', 25);
|
||||
$table->text('content');
|
||||
$table->text('attachments');
|
||||
$table->text('tool_calls');
|
||||
$table->text('tool_results');
|
||||
$table->text('usage');
|
||||
$table->text('meta');
|
||||
$table->timestamps();
|
||||
|
||||
$table->index(['conversation_id', 'user_id', 'updated_at'], 'conversation_index');
|
||||
$table->index(['user_id']);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('agent_conversations');
|
||||
Schema::dropIfExists('agent_conversation_messages');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
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::table('agent_conversations', function (Blueprint $table) {
|
||||
$table->nullableUuidMorphs('chatable');
|
||||
$table->unique(['user_id', 'chatable_type', 'chatable_id'], 'chat_with_unique');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('agent_conversations', function (Blueprint $table) {
|
||||
$table->dropUnique('chat_with_unique');
|
||||
$table->dropMorphs('chatable');
|
||||
});
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user