Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
11791263e0 | ||
|
|
1117cadf2a |
+8
-2
@@ -331,6 +331,12 @@ tasks:
|
|||||||
cmds:
|
cmds:
|
||||||
- fvm dart run scripts/check_coverage.dart
|
- fvm dart run scripts/check_coverage.dart
|
||||||
|
|
||||||
|
check-coverage:
|
||||||
|
desc: Run unit+widget tests with coverage, then fail if the gate is not met
|
||||||
|
deps: [test]
|
||||||
|
cmds:
|
||||||
|
- task: coverage
|
||||||
|
|
||||||
website-dev:
|
website-dev:
|
||||||
desc: Run Hugo development server
|
desc: Run Hugo development server
|
||||||
cmds:
|
cmds:
|
||||||
@@ -361,8 +367,8 @@ tasks:
|
|||||||
${SSH_USER}@${SSH_HOST}:public_html/
|
${SSH_USER}@${SSH_HOST}:public_html/
|
||||||
|
|
||||||
check-fast:
|
check-fast:
|
||||||
desc: Pre-commit checks — analyze + unit tests + widget tests (no build, no integration)
|
desc: Pre-commit checks — analyze + unit+widget tests + coverage gate (no build, no integration)
|
||||||
deps: [analyze, test, check-hygiene]
|
deps: [analyze, check-coverage, check-hygiene]
|
||||||
|
|
||||||
check-hygiene:
|
check-hygiene:
|
||||||
desc: Verify that no forbidden files (like home dir config) are tracked
|
desc: Verify that no forbidden files (like home dir config) are tracked
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ class AppDatabase extends _$AppDatabase {
|
|||||||
AppDatabase([QueryExecutor? executor]) : super(executor ?? _openConnection());
|
AppDatabase([QueryExecutor? executor]) : super(executor ?? _openConnection());
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int get schemaVersion => 24;
|
int get schemaVersion => 25;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
MigrationStrategy get migration => MigrationStrategy(
|
MigrationStrategy get migration => MigrationStrategy(
|
||||||
@@ -431,6 +431,22 @@ class AppDatabase extends _$AppDatabase {
|
|||||||
if (from >= 4 && from < 24) {
|
if (from >= 4 && from < 24) {
|
||||||
await m.addColumn(drafts, drafts.imapServerId);
|
await m.addColumn(drafts, drafts.imapServerId);
|
||||||
}
|
}
|
||||||
|
if (from < 25) {
|
||||||
|
// For observeMailboxes: filter by account_id, sort by path.
|
||||||
|
await m.createIndex(
|
||||||
|
Index(
|
||||||
|
'mailboxes_account_id',
|
||||||
|
'CREATE INDEX IF NOT EXISTS mailboxes_account_id ON mailboxes (account_id, path);',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
// For observeThreads: filter by account_id+mailbox_path, sort by latest_date.
|
||||||
|
await m.createIndex(
|
||||||
|
Index(
|
||||||
|
'threads_latest_date',
|
||||||
|
'CREATE INDEX IF NOT EXISTS threads_latest_date ON threads (account_id, mailbox_path, latest_date DESC);',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ void main() {
|
|||||||
group('Migration', () {
|
group('Migration', () {
|
||||||
test('schemaVersion matches expected value', () async {
|
test('schemaVersion matches expected value', () async {
|
||||||
final db = AppDatabase(NativeDatabase.memory());
|
final db = AppDatabase(NativeDatabase.memory());
|
||||||
expect(db.schemaVersion, 24);
|
expect(db.schemaVersion, 25);
|
||||||
await db.close();
|
await db.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -141,6 +141,23 @@ void main() {
|
|||||||
]),
|
]),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// v18, v22, v25: indexes.
|
||||||
|
final allIndexes = await db
|
||||||
|
.customSelect("SELECT name FROM sqlite_master WHERE type='index'")
|
||||||
|
.get();
|
||||||
|
final indexNames = allIndexes.map((r) => r.read<String>('name')).toSet();
|
||||||
|
expect(
|
||||||
|
indexNames,
|
||||||
|
containsAll([
|
||||||
|
'emails_received_at', // v18
|
||||||
|
'emails_thread_id', // v18
|
||||||
|
'pending_changes_account_id', // v18
|
||||||
|
'emails_snoozed_until', // v22
|
||||||
|
'mailboxes_account_id', // v25
|
||||||
|
'threads_latest_date', // v25
|
||||||
|
]),
|
||||||
|
);
|
||||||
|
|
||||||
await db.close();
|
await db.close();
|
||||||
if (dbFile.existsSync()) dbFile.deleteSync();
|
if (dbFile.existsSync()) dbFile.deleteSync();
|
||||||
});
|
});
|
||||||
@@ -186,6 +203,17 @@ void main() {
|
|||||||
updated_at INTEGER NOT NULL
|
updated_at INTEGER NOT NULL
|
||||||
);
|
);
|
||||||
''');
|
''');
|
||||||
|
rawDb.execute('''
|
||||||
|
CREATE TABLE mailboxes (
|
||||||
|
id TEXT NOT NULL PRIMARY KEY,
|
||||||
|
account_id TEXT NOT NULL,
|
||||||
|
path TEXT NOT NULL,
|
||||||
|
name TEXT NOT NULL,
|
||||||
|
unread_count INTEGER NOT NULL DEFAULT 0,
|
||||||
|
total_count INTEGER NOT NULL DEFAULT 0,
|
||||||
|
role TEXT NULL
|
||||||
|
);
|
||||||
|
''');
|
||||||
rawDb.execute('''
|
rawDb.execute('''
|
||||||
CREATE TABLE emails (
|
CREATE TABLE emails (
|
||||||
id TEXT NOT NULL PRIMARY KEY,
|
id TEXT NOT NULL PRIMARY KEY,
|
||||||
@@ -210,6 +238,23 @@ void main() {
|
|||||||
snoozed_from_mailbox_path TEXT NULL
|
snoozed_from_mailbox_path TEXT NULL
|
||||||
);
|
);
|
||||||
''');
|
''');
|
||||||
|
rawDb.execute('''
|
||||||
|
CREATE TABLE threads (
|
||||||
|
account_id TEXT NOT NULL,
|
||||||
|
mailbox_path TEXT NOT NULL,
|
||||||
|
id TEXT NOT NULL,
|
||||||
|
subject TEXT NULL,
|
||||||
|
latest_date INTEGER NOT NULL,
|
||||||
|
message_count INTEGER NOT NULL DEFAULT 1,
|
||||||
|
has_unread INTEGER NOT NULL DEFAULT 0 CHECK ("has_unread" IN (0, 1)),
|
||||||
|
is_flagged INTEGER NOT NULL DEFAULT 0 CHECK ("is_flagged" IN (0, 1)),
|
||||||
|
participants_json TEXT NOT NULL DEFAULT '[]',
|
||||||
|
preview TEXT NULL,
|
||||||
|
latest_email_id TEXT NOT NULL,
|
||||||
|
email_ids_json TEXT NOT NULL DEFAULT '[]',
|
||||||
|
PRIMARY KEY (account_id, mailbox_path, id)
|
||||||
|
);
|
||||||
|
''');
|
||||||
rawDb.execute('PRAGMA user_version = 22;');
|
rawDb.execute('PRAGMA user_version = 22;');
|
||||||
rawDb.close();
|
rawDb.close();
|
||||||
|
|
||||||
@@ -223,11 +268,19 @@ void main() {
|
|||||||
final draftColumns = await _tableColumns(db, 'drafts');
|
final draftColumns = await _tableColumns(db, 'drafts');
|
||||||
expect(draftColumns, contains('imap_server_id'));
|
expect(draftColumns, contains('imap_server_id'));
|
||||||
|
|
||||||
|
// v25: new indexes on mailboxes and threads.
|
||||||
|
final allIndexes = await db
|
||||||
|
.customSelect("SELECT name FROM sqlite_master WHERE type='index'")
|
||||||
|
.get();
|
||||||
|
final indexNames = allIndexes.map((r) => r.read<String>('name')).toSet();
|
||||||
|
expect(indexNames, contains('mailboxes_account_id'));
|
||||||
|
expect(indexNames, contains('threads_latest_date'));
|
||||||
|
|
||||||
await db.close();
|
await db.close();
|
||||||
if (dbFile.existsSync()) dbFile.deleteSync();
|
if (dbFile.existsSync()) dbFile.deleteSync();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('fresh install creates all tables at schemaVersion 24', () async {
|
test('fresh install creates all tables at schemaVersion 25', () async {
|
||||||
final db = AppDatabase(NativeDatabase.memory());
|
final db = AppDatabase(NativeDatabase.memory());
|
||||||
await db.select(db.accounts).get();
|
await db.select(db.accounts).get();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user