@bobfrankston/mailx 1.0.232 → 1.0.233

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bobfrankston/mailx",
3
- "version": "1.0.232",
3
+ "version": "1.0.233",
4
4
  "description": "Local-first email client with IMAP sync and standalone native app",
5
5
  "type": "module",
6
6
  "main": "bin/mailx.js",
@@ -24,7 +24,7 @@
24
24
  "@bobfrankston/iflow-node": "^0.1.2",
25
25
  "@bobfrankston/miscinfo": "^1.0.8",
26
26
  "@bobfrankston/oauthsupport": "^1.0.22",
27
- "@bobfrankston/msger": "^0.1.294",
27
+ "@bobfrankston/msger": "^0.1.295",
28
28
  "@capacitor/android": "^8.3.0",
29
29
  "@capacitor/cli": "^8.3.0",
30
30
  "@capacitor/core": "^8.3.0",
@@ -78,7 +78,7 @@
78
78
  "@bobfrankston/iflow-node": "^0.1.2",
79
79
  "@bobfrankston/miscinfo": "^1.0.8",
80
80
  "@bobfrankston/oauthsupport": "^1.0.22",
81
- "@bobfrankston/msger": "^0.1.294",
81
+ "@bobfrankston/msger": "^0.1.295",
82
82
  "@capacitor/android": "^8.3.0",
83
83
  "@capacitor/cli": "^8.3.0",
84
84
  "@capacitor/core": "^8.3.0",
@@ -127,8 +127,10 @@ export class MailxDB {
127
127
  this.db.exec("PRAGMA foreign_keys = ON");
128
128
  this.db.exec(SCHEMA);
129
129
  // Idempotent migrations for older databases that predate new columns.
130
- // SQLite doesn't support "ADD COLUMN IF NOT EXISTS", so we probe the
131
- // table schema and add missing columns one by one.
130
+ // SQLite doesn't support "ADD COLUMN IF NOT EXISTS", so we just try the
131
+ // ALTER and catch the "duplicate column" error. Simpler and more robust
132
+ // than probing via PRAGMA table_info (which can behave differently
133
+ // across sqlite drivers).
132
134
  this.addColumnIfMissing("messages", "thread_id", "TEXT");
133
135
  try {
134
136
  this.db.exec("CREATE INDEX IF NOT EXISTS idx_messages_thread_id ON messages(account_id, thread_id)");
@@ -137,10 +139,17 @@ export class MailxDB {
137
139
  }
138
140
  /** Idempotently add a column to a table if it's missing. */
139
141
  addColumnIfMissing(table, column, sqlType) {
140
- const cols = this.db.prepare(`PRAGMA table_info(${table})`).all();
141
- if (cols.some(c => c.name === column))
142
- return;
143
- this.db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${sqlType}`);
142
+ try {
143
+ this.db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${sqlType}`);
144
+ console.log(` [db] added column ${table}.${column}`);
145
+ }
146
+ catch (e) {
147
+ const msg = String(e?.message || e);
148
+ // "duplicate column name" is the expected case when column already exists
149
+ if (!/duplicate column/i.test(msg)) {
150
+ console.error(` [db] migration ${table}.${column} failed: ${msg}`);
151
+ }
152
+ }
144
153
  }
145
154
  /** Compute a thread id for an incoming message. Strategy:
146
155
  * 1. If any ancestor (in_reply_to or references) is already present in