hyperf-chat/migrations/2020_11_04_153553_create_co...

40 lines
1.3 KiB
PHP
Raw Normal View History

2020-11-04 16:47:17 +08:00
<?php
use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;
2020-12-03 16:22:55 +08:00
2022-01-21 22:19:42 +08:00
class CreateContactTable extends Migration
2020-11-04 16:47:17 +08:00
{
/**
* Run the migrations.
*/
public function up(): void
{
2022-01-21 22:19:42 +08:00
Schema::create('contact', function (Blueprint $table) {
2020-11-04 16:47:17 +08:00
$table->unsignedInteger('id', true)->comment('关系ID');
2021-07-08 19:09:06 +08:00
$table->unsignedInteger('user_id')->default(0)->comment('用户ID');
$table->unsignedInteger('friend_id')->default(0)->comment('好友ID');
$table->string('remark', 30)->default('')->comment('好友备注');
$table->unsignedTinyInteger('status')->default(0)->comment('好友状态[0:否;1:是;]');
2020-11-04 16:47:17 +08:00
$table->dateTime('created_at')->nullable(true)->comment('创建时间');
2021-07-08 19:09:06 +08:00
$table->dateTime('updated_at')->nullable(true)->comment('更新时间');
2020-11-04 16:47:17 +08:00
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-07-08 19:09:06 +08:00
$table->index(['user_id', 'friend_id'], 'idx_user_id_friend_id');
2021-08-27 23:50:40 +08:00
$table->comment('用户好友关系表');
2020-11-04 16:47:17 +08:00
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
2022-01-21 22:19:42 +08:00
Schema::dropIfExists('contact');
2020-11-04 16:47:17 +08:00
}
}