Printing tracking for owned copies and deck art, and an outdated-card-data notice
Owned copies can now be pinned to a printing + finish (nonfoil / foil / etched), activating the long-dormant library_card_copies table as groups of identical copies. library_cards.quantity_owned stays authoritative: groups are a subset of it, and the rest are "unspecified". Tracking more copies than are unspecified grows ownership to fit; lowering ownership trims the most recently added groups first. Migration 0006 adds the group quantity, a unique (card, printing, finish) index, and deck_cards.preferred_scryfall_id. A deck slot can show a chosen printing's art, both faces from that printing, falling back to the default when the id no longer resolves. It survives quantity/board changes and is kept by duplicate_deck. UI: the click preview's info tile gets a Printings section when opened from the Library or a deck (copy groups with steppers, "Add a printing…", and "Shown in this deck" with Change…/Default), backed by a printing picker grid. The picker takes Escape in the capture phase so it closes without closing the preview under it. Sync: CardEntry.printings (keyed "<scryfall_id>/<finish>") and DeckCardEntry.printing. Cards now merge field by field with groups per key, so a quantity edit and a printing added on another device both survive; merged groups are clamped deterministically. A document is written as version 2 only once it holds printing data, so older builds and servers refuse it instead of dropping the data and syncing the loss. Decklists: "(SET) NUM", optionally "*F*"/"*E*", round-trips through deck and library export/import. Library export writes a line per group plus one for unspecified copies. reference.db printings gain lang and released_at for picker labels and ordering. When the installed card data lacks any column this build's reference schema has (found by diffing against the schema applied in-memory, so no list to maintain), a notice under the top bar offers Update card data (and Import card data… on phones); "Not now" is remembered until something more goes missing.
This commit is contained in:
15
crates/mtgc-core/src/sql/library/0006_printings.sql
Normal file
15
crates/mtgc-core/src/sql/library/0006_printings.sql
Normal file
@@ -0,0 +1,15 @@
|
||||
-- v6 — optional per-printing tracking (see docs/printing-tracking-design.md).
|
||||
--
|
||||
-- `library_card_copies` has existed since v1 but was never written. Each row now
|
||||
-- means "`quantity` of my copies of this card are this printing + finish": a
|
||||
-- group of identical copies rather than one row per physical card. Groups are
|
||||
-- a subset of `library_cards.quantity_owned`, which stays authoritative for
|
||||
-- totals; any copies not covered by a group are simply unspecified.
|
||||
ALTER TABLE library_card_copies ADD COLUMN quantity INTEGER NOT NULL DEFAULT 1;
|
||||
CREATE UNIQUE INDEX idx_copies_printing
|
||||
ON library_card_copies(library_card_id, scryfall_id, finish);
|
||||
|
||||
-- Which printing's art to show for a deck slot. A pure display preference:
|
||||
-- printings live in the rebuildable reference.db, so there's no foreign key,
|
||||
-- and an id that no longer resolves just falls back to the default image.
|
||||
ALTER TABLE deck_cards ADD COLUMN preferred_scryfall_id TEXT;
|
||||
@@ -94,7 +94,11 @@ CREATE TABLE IF NOT EXISTS printings (
|
||||
-- Boolean: this printing isn't available on paper (Scryfall `games`).
|
||||
digital INTEGER NOT NULL DEFAULT 0,
|
||||
-- Boolean: this printing comes from a "funny" set (Scryfall `set_type`).
|
||||
funny INTEGER NOT NULL DEFAULT 0
|
||||
funny INTEGER NOT NULL DEFAULT 0,
|
||||
-- Scryfall language code ("en", "ja", ...) and release date (YYYY-MM-DD),
|
||||
-- for labelling and ordering printings in the printing picker.
|
||||
lang TEXT NOT NULL DEFAULT '',
|
||||
released_at TEXT NOT NULL DEFAULT ''
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_printings_oid ON printings(oracle_id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user