hyperf-chat/migrations/2020_11_04_153421_create_ta...

43 lines
1.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
class CreateTalkSessionTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('talk_session', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('聊天列表ID');
$table->unsignedTinyInteger('talk_type')->default(1)->comment('聊天类型[1:私信;2:群聊;]');
$table->unsignedInteger('user_id')->default(0)->comment('用户ID');
$table->unsignedInteger('receiver_id')->default(0)->comment('接收者ID用户ID 或 群ID');
$table->unsignedTinyInteger('is_top')->default(0)->comment('是否置顶[0:否;1:是]');
$table->unsignedTinyInteger('is_robot')->default(0)->comment('是否机器人[0:否;1:是;]');
$table->unsignedTinyInteger('is_delete')->default(0)->comment('是否删除[0:否;1:是;]');
$table->unsignedTinyInteger('is_disturb')->default(0)->comment('消息免打扰[0:否;1:是;]');
$table->dateTime('created_at')->nullable(true)->comment('创建时间');
$table->dateTime('updated_at')->nullable(true)->comment('更新时间');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
$table->engine = 'InnoDB';
$table->unique(['user_id', 'receiver_id', 'talk_type'], 'uk_user_id_receiver_id_talk_type');
$table->comment('用户聊天列表');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('talk_session');
}
}