hyperf-chat/migrations/2020_11_04_153421_create_ta...

43 lines
1.7 KiB
PHP
Raw Permalink Normal View History

2021-07-08 19:09:06 +08:00
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
2022-01-21 22:19:42 +08:00
class CreateTalkSessionTable extends Migration
2021-07-08 19:09:06 +08:00
{
/**
* Run the migrations.
*/
public function up(): void
{
2022-01-21 22:19:42 +08:00
Schema::create('talk_session', function (Blueprint $table) {
2021-07-08 19:09:06 +08:00
$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';
2021-10-27 21:05:53 +08:00
$table->unique(['user_id', 'receiver_id', 'talk_type'], 'uk_user_id_receiver_id_talk_type');
2021-08-27 23:50:40 +08:00
$table->comment('用户聊天列表');
2021-07-08 19:09:06 +08:00
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
2022-01-21 22:19:42 +08:00
Schema::dropIfExists('talk_session');
2021-07-08 19:09:06 +08:00
}
}