table('system_notice') ->setComment('系统通知表') ->addColumn('scene', 'string', ['limit' => 50, 'null' => true, 'default' => 'common', 'comment' => '通知场景']) ->addColumn('title', 'string', ['limit' => 255, 'null' => true, 'comment' => '通知标题']) ->addColumn('content', 'text', ['null' => true, 'comment' => '通知内容']) ->addColumn('biz_id', 'string', ['limit' => 64, 'null' => true, 'default' => '', 'comment' => '业务关联ID']) ->addColumn('send_admin_id', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '发送管理员ID']) ->addColumn('create_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '创建时间']) ->addColumn('update_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false]) ->addColumn('delete_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false]) ->addIndex(['scene'], ['name' => 'idx_scene']) ->addIndex(['create_time'], ['name' => 'idx_create_time']) ->create(); $this->table('system_notice_target') ->setComment('系统通知投递目标表') ->addColumn('notice_id', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '通知ID']) ->addColumn('admin_id', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '接收管理员ID']) ->addColumn('channel', 'string', ['limit' => 20, 'null' => true, 'comment' => '投递渠道']) ->addColumn('target_addr', 'string', ['limit' => 255, 'null' => true, 'default' => '', 'comment' => '投递目标地址']) ->addColumn('status', 'tinyinteger', ['limit' => 1, 'null' => true, 'default' => 0, 'comment' => '状态:0=待发,1=发送中,2=成功,3=失败']) ->addColumn('send_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '发送时间']) ->addColumn('read_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '阅读时间']) ->addColumn('claim_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '抢占时间']) ->addColumn('claim_token', 'string', ['limit' => 32, 'null' => true, 'default' => '', 'comment' => '抢占令牌']) ->addColumn('retry_count', 'tinyinteger', ['limit' => 1, 'null' => true, 'default' => 0, 'comment' => '重试次数']) ->addColumn('next_retry_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '下次重试时间']) ->addColumn('error_message', 'string', ['limit' => 500, 'null' => true, 'default' => '', 'comment' => '错误信息']) ->addColumn('create_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '创建时间']) ->addColumn('update_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false]) ->addIndex(['status', 'id'], ['name' => 'idx_status_id']) ->addIndex(['admin_id', 'channel', 'read_time'], ['name' => 'idx_admin_channel_read']) ->addIndex(['notice_id'], ['name' => 'idx_notice_id']) ->create(); $this->table('system_notice_subscribe') ->setComment('系统通知订阅表') ->addColumn('admin_id', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '管理员ID']) ->addColumn('scene', 'string', ['limit' => 50, 'null' => true, 'comment' => '通知场景']) ->addColumn('channel', 'string', ['limit' => 20, 'null' => true, 'comment' => '投递渠道']) ->addColumn('status', 'tinyinteger', ['limit' => 1, 'null' => true, 'default' => 1, 'comment' => '订阅状态:0=退订,1=订阅']) ->addColumn('create_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '创建时间']) ->addColumn('update_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false]) ->addIndex(['admin_id', 'scene', 'channel'], ['unique' => true, 'name' => 'uniq_admin_scene_channel']) ->create(); } }