Files
iAs/ias-service/migrations/20260706016000_mail_accounts_and_cache.sql
T
wunianxiao 25dd0daa8b feat: 模块统一 ias- 前缀、独立版本与内网地址支持 (0.1.7)
- 所有 Rust crate 统一加 ias- 前缀:ai → ias-ai、common → ias-common、context → ias-context、mail → ias-mail、service → ias-service、wechat → ias-wechat
- 新增 ias-main 模块承载 CLI 入口和二进制打包
- 各模块开始独立维护版本号,ias-main 0.1.7 代表整体版本
- 新增 IA_WEB_INTERNAL_URL 环境变量,版本通知同时发送公网和内网链接
- 将已有升级日志翻译为中文
- ias_upgrade_logs 新增 modules JSONB 字段
- 新增 VERSION 文件和 CHANGELOG.md
- 新增 AGENTS.md 项目规则文件
2026-07-06 17:57:48 +08:00

57 lines
2.2 KiB
SQL

CREATE TABLE ias_mail_accounts (
id BIGSERIAL PRIMARY KEY,
name VARCHAR(255) NOT NULL,
source_key VARCHAR(512) NOT NULL UNIQUE,
imap_host VARCHAR(255) NOT NULL,
imap_port INTEGER NOT NULL DEFAULT 993,
imap_username TEXT NOT NULL,
imap_password TEXT NOT NULL,
mailbox VARCHAR(255) NOT NULL DEFAULT 'INBOX',
notify_account_id VARCHAR(255) NOT NULL,
notify_user_id VARCHAR(255) NOT NULL,
poll_seconds INTEGER NOT NULL DEFAULT 60,
fetch_limit INTEGER NOT NULL DEFAULT 10,
accept_invalid_certs BOOLEAN NOT NULL DEFAULT FALSE,
enabled BOOLEAN NOT NULL DEFAULT TRUE,
last_checked_at TIMESTAMPTZ,
last_error TEXT,
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_ias_mail_accounts_enabled
ON ias_mail_accounts(enabled, id);
ALTER TABLE ias_mail_messages
ADD COLUMN mail_account_id BIGINT REFERENCES ias_mail_accounts(id) ON DELETE SET NULL,
ADD COLUMN content TEXT NOT NULL DEFAULT '',
ADD COLUMN raw_headers TEXT;
CREATE INDEX idx_ias_mail_messages_account
ON ias_mail_messages(mail_account_id, created_at DESC);
INSERT INTO ias_upgrade_logs (
version,
released_at,
title,
description,
changes
) VALUES (
'0.1.5',
'2026-07-06T00:00:00+08:00',
'Database-backed mail auth and cache',
'Added guided mail account configuration with ias mail auth, persisted mail accounts in the database, and expanded mail message caching.',
'[
"Added database-backed mail account configuration through the guided ias mail auth command.",
"Added the ias_mail_accounts table and linked cached mail messages back to their configured account.",
"Extended the mail cache to persist full parsed mail content and raw headers in ias_mail_messages.",
"Updated mail polling to load enabled mail accounts from the database first, while keeping environment-based configuration as a fallback.",
"Added mail account listing through ias mail list.",
"Persisted the 0.1.5 upgrade record."
]'::jsonb
) ON CONFLICT (version) DO UPDATE SET
released_at = EXCLUDED.released_at,
title = EXCLUDED.title,
description = EXCLUDED.description,
changes = EXCLUDED.changes;