ensureSchema method
Implementation
Future<void> ensureSchema() async {
await table.ensureSchema();
await dvEnsureFrameworkTable(
_database,
'CREATE TABLE IF NOT EXISTS $logTable (seq BIGINT, mutation_id TEXT, '
'op TEXT, record_key TEXT, payload TEXT, state TEXT, rejection TEXT)',
);
await _database.execute(
'CREATE TABLE IF NOT EXISTS $serverTable (record_key TEXT, '
'version INTEGER, payload TEXT)',
);
final List<Map<String, Object?>> last = await _database
.query('SELECT seq FROM $logTable ORDER BY seq DESC LIMIT 1');
_sequence = last.isEmpty ? 0 : (last.first['seq']! as num).toInt();
for (final DVMutation m in await pending()) {
_states[m.key] = DVSyncState.pending;
}
for (final DVMutation m in await rejected()) {
_states[m.key] = DVSyncState.rejected;
}
if (!persistent) {
_report(
'DV-OFFLINE-001',
'${table.table} has no writable storage on this device; its offline '
'store is memory-backed and will not survive the application '
'closing.',
DVLogLevel.warn,
);
}
}