2020-11-04 16:47:17 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Hyperf\Database\Schema\Schema;
|
|
|
|
use Hyperf\Database\Schema\Blueprint;
|
|
|
|
use Hyperf\Database\Migrations\Migration;
|
|
|
|
use Hyperf\DbConnection\Db;
|
2021-03-25 17:32:36 +08:00
|
|
|
|
|
|
|
class CreateGroupNoticeTable extends Migration
|
2020-11-04 16:47:17 +08:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Run the migrations.
|
|
|
|
*/
|
|
|
|
public function up(): void
|
|
|
|
{
|
2021-04-10 13:55:21 +08:00
|
|
|
Schema::create('group_notice', function (Blueprint $table) {
|
2021-03-25 17:32:36 +08:00
|
|
|
$table->unsignedInteger('id', true)->comment('群公告ID');
|
|
|
|
$table->unsignedInteger('group_id')->default(0)->comment('群组ID');
|
|
|
|
$table->unsignedInteger('creator_id')->default(0)->comment('创建者用户ID');
|
|
|
|
$table->string('title', 50)->default('')->charset('utf8mb4')->comment('公告标题');
|
2020-11-04 16:47:17 +08:00
|
|
|
$table->text('content')->charset('utf8mb4')->comment('公告内容');
|
2021-03-25 17:32:36 +08:00
|
|
|
$table->tinyInteger('is_top')->default(0)->comment('是否置顶[0:否;1:是;]');
|
|
|
|
$table->tinyInteger('is_delete')->default(0)->comment('是否删除[0:否;1:是;]');
|
|
|
|
$table->tinyInteger('is_confirm')->default(0)->comment('是否需群成员确认公告[0:否;1:是;]');
|
|
|
|
$table->json('confirm_users')->nullable()->comment('已确认成员');
|
2020-11-04 16:47:17 +08:00
|
|
|
$table->dateTime('created_at')->nullable()->comment('创建时间');
|
|
|
|
$table->dateTime('updated_at')->nullable()->comment('更新时间');
|
|
|
|
$table->dateTime('deleted_at')->nullable()->comment('删除时间');
|
|
|
|
|
2021-07-08 19:09:06 +08:00
|
|
|
$table->charset = 'utf8';
|
2020-11-04 16:47:17 +08:00
|
|
|
$table->collation = 'utf8_general_ci';
|
2021-07-08 19:09:06 +08:00
|
|
|
$table->engine = 'InnoDB';
|
2020-11-04 16:47:17 +08:00
|
|
|
|
2021-03-25 17:32:36 +08:00
|
|
|
$table->index(['group_id', 'is_delete', 'is_top', 'updated_at'], 'idx_group_id_is_delete_is_top_updated_at');
|
2020-11-04 16:47:17 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
$prefix = config('databases.default.prefix');
|
2021-03-25 17:32:36 +08:00
|
|
|
DB::statement("ALTER TABLE `{$prefix}group_notice` comment '群组公告表'");
|
2020-11-04 16:47:17 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Reverse the migrations.
|
|
|
|
*/
|
|
|
|
public function down(): void
|
|
|
|
{
|
2021-03-25 17:32:36 +08:00
|
|
|
Schema::dropIfExists('group_notice');
|
2020-11-04 16:47:17 +08:00
|
|
|
}
|
|
|
|
}
|