<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTableNoticeRule extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('notice_rule', function (Blueprint $table) {
            $table->bigIncrements('id');

            $table->string('title', 32)
                ->default('')
                ->comment('标题');

            $table->string('content', 500)
                ->default('')
                ->comment('内容');

            $table->tinyInteger('notice_status')
                ->default(0)
                ->comment('通知状态:0:未发送,1发送中,2已发送');

            $table->tinyInteger('notice_type')
                ->default(0)
                ->comment('通知类型:0push,1短信');

            $table->tinyInteger('notice_user_type')
                ->default(0)
                ->comment('通知用户类型:0全部,1条件筛选,2ID群发');

            $table->json('notice_users')
                ->nullable()
                ->comment('通知用户:attribute,category,ids');

            $table->string('action_type', 16)
                ->default('')
                ->comment('跳转内容');

            $table->integer('action_id')
                ->default(0)
                ->comment('跳转id');

            $table->string('post_type', 16)
                ->default('')
                ->comment('内容类型');

            $table->string('cover', 255)
                ->default('')
                ->comment('封面图');

            $table->integer('send_count')
                ->default(0)
                ->comment('发送数量');

            $table->dateTime('send_time')
                ->nullable()
                ->comment('发送时间');

            $table->softDeletes();

            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('notice_rule');
    }
}