-- V88: 巡查APP相关表 - Issue #88 -- PAT-21~PAT-29 -- 用户巡检统计(按月汇总) CREATE TABLE IF NOT EXISTS patrol_user_stats_monthly ( id BIGSERIAL PRIMARY KEY, user_id BIGINT NOT NULL, year_month VARCHAR(7) NOT NULL, -- '2026-06' completed_tasks INT DEFAULT 0, total_distance DOUBLE PRECISION DEFAULT 0, issue_count INT DEFAULT 0, patrol_hours DOUBLE PRECISION DEFAULT 0, created_at TIMESTAMPTZ DEFAULT NOW(), updated_at TIMESTAMPTZ DEFAULT NOW(), UNIQUE(user_id, year_month) ); CREATE INDEX IF NOT EXISTS idx_patrol_stats_user ON patrol_user_stats_monthly(user_id, year_month); -- 问题上报表加 voice_url 字段(patrol_problem 已在 problem_reporting.sql 创建) ALTER TABLE patrol_problem ADD COLUMN IF NOT EXISTS voice_url VARCHAR(500); -- 用户头像(如果 sys_user 表无 avatar 字段则添加) ALTER TABLE sys_user ADD COLUMN IF NOT EXISTS avatar VARCHAR(500);