hyperf-chat/migrations/2020_11_04_153541_create_us...

37 lines
1.0 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;
use Hyperf\DbConnection\Db;
class CreateUsersEmoticonTable extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::create('users_emoticon', function (Blueprint $table) {
$table->unsignedInteger('id', true)->comment('表情包收藏ID');
2021-08-01 19:57:41 +08:00
$table->unsignedInteger('user_id')->default(0)->comment('用户ID');
2020-11-04 16:47:17 +08:00
$table->string('emoticon_ids', 255)->default('')->comment('表情包ID');
$table->charset = 'utf8';
$table->collation = 'utf8_general_ci';
2021-08-01 19:57:41 +08:00
$table->unique(['user_id'], 'uk_user_id');
2020-11-04 16:47:17 +08:00
});
$prefix = config('databases.default.prefix');
DB::statement("ALTER TABLE `{$prefix}users_emoticon` comment '用户收藏表情包'");
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('users_emoticon');
}
}