Problem
Anki 2.1.49+ stores collection metadata in separate SQLite tables (notetypes, templates, fields, deck_config, config, tags) and leaves the legacy col.{models,decks,conf,dconf,tags} JSON columns as empty strings. spacedrep currently reads only the legacy col.* JSONs, so any collection produced by recent Anki Desktop (or exported without "Support older Anki versions" checked) is rejected with UnsupportedCollectionFormatError instead of being usable.
The error was added in the previous patch so the failure is at least actionable — users get a clear message pointing them to re-export in the legacy format. This issue tracks the underlying compatibility work.
Scope sketch
- Read path: load note-type/template/field metadata from
notetypes + templates + fields, decks from decks + deck_config, config from config, tags from tags. Feed these into the existing ColMeta / ModelInfo shapes so the rest of the code doesn't need to branch.
- Write path: mirror writes into the new tables (or the DB diverges from what Anki expects on re-open). This is the harder half — it's a read + write project, not just a reader.
- Detection:
db.is_modern_anki_schema(conn) already identifies these DBs; the boundary checks in core._open_db / core.open_deck would become "use the modern reader" instead of "raise".
Design notes
- Model IDs and shapes differ between
col.models JSON (Anki ≤2.1.48) and the notetypes/templates/fields row layout — a translation layer will be needed.
col.ver is likely the cleanest runtime signal for which schema the DB uses; confirm before relying on it.
- Consider whether
spacedrep db init should produce legacy-format or modern-format DBs once support lands; probably legacy for simplicity until the modern writer is complete.
Repro
# Any collection.anki21 from recent Anki Desktop:
spacedrep card list --db /path/to/collection.anki21
# => {"error": "unsupported_collection_format", ...}
Workaround today
Export from Anki Desktop as an .apkg with "Support older Anki versions" checked (File → Export), then spacedrep deck import the resulting .apkg.
Problem
Anki 2.1.49+ stores collection metadata in separate SQLite tables (
notetypes,templates,fields,deck_config,config,tags) and leaves the legacycol.{models,decks,conf,dconf,tags}JSON columns as empty strings. spacedrep currently reads only the legacycol.*JSONs, so any collection produced by recent Anki Desktop (or exported without "Support older Anki versions" checked) is rejected withUnsupportedCollectionFormatErrorinstead of being usable.The error was added in the previous patch so the failure is at least actionable — users get a clear message pointing them to re-export in the legacy format. This issue tracks the underlying compatibility work.
Scope sketch
notetypes+templates+fields, decks fromdecks+deck_config, config fromconfig, tags fromtags. Feed these into the existingColMeta/ModelInfoshapes so the rest of the code doesn't need to branch.db.is_modern_anki_schema(conn)already identifies these DBs; the boundary checks incore._open_db/core.open_deckwould become "use the modern reader" instead of "raise".Design notes
col.modelsJSON (Anki ≤2.1.48) and thenotetypes/templates/fieldsrow layout — a translation layer will be needed.col.veris likely the cleanest runtime signal for which schema the DB uses; confirm before relying on it.spacedrep db initshould produce legacy-format or modern-format DBs once support lands; probably legacy for simplicity until the modern writer is complete.Repro
Workaround today
Export from Anki Desktop as an .apkg with "Support older Anki versions" checked (File → Export), then
spacedrep deck importthe resulting .apkg.