#!/usr/bin/env node import crypto from 'node:crypto'; import mysql from 'mysql2/promise'; import { zonedTimeToEpochMs } from '../schedule-time.mjs'; const pool = mysql.createPool(process.env.DATABASE_URL ?? 'mysql://boot:888888@localhost:3306/memind'); const uid = '1c99b83b-0454-474f-a5d2-129d34506a32'; const tz = 'Asia/Shanghai'; const t = (y, m, d, h, mi) => zonedTimeToEpochMs({ year: y, month: m, day: d, hour: h, minute: mi, second: 0 }, tz); const badItems = [ 'f058e736-1e6d-4559-8399-36cb91d67634', 'be571e96-365c-4a0a-806a-491089e02144', '03ff84f1-3ac0-4fc6-ab7e-9fe2064fbf15', ]; await pool.query('DELETE FROM h5_schedule_reminders WHERE item_id IN (?)', [badItems]); await pool.query('DELETE FROM h5_schedule_items WHERE id IN (?)', [badItems]); await pool.query( 'UPDATE h5_schedule_items SET kind=?, start_at=?, end_at=? WHERE id=?', ['event', t(2026, 7, 1, 6, 0), t(2026, 7, 1, 6, 30), '8b34b44e-84cf-462b-86a4-e895e656d626'], ); await pool.query( 'UPDATE h5_schedule_items SET start_at=?, end_at=? WHERE id=?', [t(2026, 7, 1, 12, 0), t(2026, 7, 1, 13, 0), '6fb372ca-3537-4f63-8a8c-d30615d6e832'], ); await pool.query('UPDATE h5_schedule_reminders SET remind_at=? WHERE id=?', [ t(2026, 7, 1, 5, 55), '633b008a-791b-455c-8f3b-331d5c7b1971', ]); await pool.query('UPDATE h5_schedule_reminders SET remind_at=? WHERE id=?', [ t(2026, 7, 1, 11, 50), 'e423c8be-7463-481a-b881-131cb32b6f99', ]); const [existingDinner] = await pool.query( `SELECT id FROM h5_schedule_items WHERE user_id=? AND title LIKE '%聚餐%' AND deleted_at IS NULL LIMIT 1`, [uid], ); if (!existingDinner[0]) { const dinnerId = crypto.randomUUID(); const now = Date.now(); await pool.query( `INSERT INTO h5_schedule_items (id, user_id, kind, title, status, start_at, end_at, all_day, timezone, source_channel, created_at, updated_at) VALUES (?, ?, 'event', ?, 'active', ?, ?, 0, ?, 'agent', ?, ?)`, [ dinnerId, uid, '同学聚餐 🍽️', t(2026, 7, 1, 18, 30), t(2026, 7, 1, 21, 0), tz, now, now, ], ); await pool.query( `INSERT INTO h5_schedule_reminders (id, user_id, item_id, remind_at, offset_minutes, channel, status, attempts, created_at, updated_at) VALUES (?, ?, ?, ?, 30, 'wechat', 'pending', 0, ?, ?)`, [crypto.randomUUID(), uid, dinnerId, t(2026, 7, 1, 18, 0), now, now], ); } const [rows] = await pool.query( `SELECT title, start_at FROM h5_schedule_items WHERE user_id=? AND deleted_at IS NULL ORDER BY start_at`, [uid], ); for (const row of rows) { console.log( row.title, new Date(Number(row.start_at)).toLocaleString('zh-CN', { timeZone: tz }), ); } await pool.end();