Files
YwxAppThink/docs/migrations/fix_missing_wxapp_notice.sql

33 lines
2.0 KiB
SQL
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- ============================================================
-- 修复:wxapp_notice 表缺失(线上报 1146
-- ============================================================
-- 背景:
-- ywxapp/model/Notice.php 的 ensureSchema() 会尝试自建 wxapp_notice
-- 但若线上数据库账号无 CREATE TABLE 权限,建表语句会被 try/catch 静默吞掉,
-- 后续 SELECT 即报 1146 Table 'ywxapp_www.wxapp_notice' doesn't exist。
-- 用法:
-- ① 先确认前缀:SELECT @@global.version 不重要,看报错里的表名前缀即可(此处为 wxapp_)。
-- ② 把下面的 wxapp_ 替换成你线上实际前缀(若不同),然后在线上库执行本文件。
-- ③ 优先方案是给线上 DB 账号授予 CREATE/ALTER 权限,自愈会自动补齐,无需手动。
-- ============================================================
CREATE TABLE IF NOT EXISTS `wxapp_notice` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(200) NOT NULL DEFAULT '' COMMENT '公告标题',
`content` text COMMENT '公告内容',
`author` varchar(50) NOT NULL DEFAULT '' COMMENT '发布人',
`type` tinyint(1) NOT NULL DEFAULT 1 COMMENT '类型 1系统维护 2活动公告 3版本更新 4其他',
`is_top` tinyint(1) NOT NULL DEFAULT 0 COMMENT '是否置顶 0否 1是',
`start_time` int(11) NOT NULL DEFAULT 0 COMMENT '展示开始时间 0=长期',
`end_time` int(11) NOT NULL DEFAULT 0 COMMENT '展示结束时间 0=长期',
`view_count` int(11) NOT NULL DEFAULT 0 COMMENT '浏览量',
`sort` int(11) NOT NULL DEFAULT 0 COMMENT '排序',
`status` tinyint(1) NOT NULL DEFAULT 1 COMMENT '状态 0禁用 1启用',
`create_at` int(11) NOT NULL DEFAULT 0 COMMENT '创建时间',
`update_at` int(11) NOT NULL DEFAULT 0 COMMENT '更新时间',
`delete_at` int(11) NOT NULL DEFAULT 0 COMMENT '删除时间',
PRIMARY KEY (`id`),
KEY `idx_type` (`type`),
KEY `idx_is_top` (`is_top`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='站点公告';