- 添加用户管理功能的测试,包括创建、更新、停用、激活用户及用户登录 JWT 测试 - 提供用户管理相关的请求验证类与控制器 - 引入 CORS 配置信息,支持跨域请求 - 添加数据库播种器以便创建根用户 - 配置 API 默认使用 JWT 认证 - 添加聊天会话和消息的模型、迁移文件及关联功能
44 lines
1.5 KiB
PHP
44 lines
1.5 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('chat_sessions', function (Blueprint $table) {
|
|
$table->uuid('session_id')->primary();
|
|
$table->string('session_name', 255)->nullable();
|
|
$table->string('status', 16)->default('OPEN');
|
|
$table->unsignedBigInteger('last_seq')->default(0);
|
|
$table->timestamps();
|
|
});
|
|
|
|
Schema::create('messages', function (Blueprint $table) {
|
|
$table->uuid('message_id')->primary();
|
|
$table->uuid('session_id');
|
|
$table->string('role', 32);
|
|
$table->string('type', 64);
|
|
$table->text('content')->nullable();
|
|
$table->jsonb('payload')->nullable();
|
|
$table->timestamp('created_at')->useCurrent();
|
|
$table->unsignedBigInteger('seq');
|
|
$table->uuid('reply_to')->nullable();
|
|
$table->string('dedupe_key', 128)->nullable();
|
|
|
|
$table->foreign('session_id')->references('session_id')->on('chat_sessions')->onDelete('cascade');
|
|
$table->unique(['session_id', 'seq']);
|
|
$table->unique(['session_id', 'dedupe_key']);
|
|
$table->index(['session_id', 'seq']);
|
|
});
|
|
}
|
|
|
|
public function down(): void
|
|
{
|
|
Schema::dropIfExists('messages');
|
|
Schema::dropIfExists('chat_sessions');
|
|
}
|
|
};
|