Data model
Cards
One row per Magic card as a game object: rules text, cost, legality. Independent of how many times it has been printed.
40 columns. Every value below is generated from the provenance registry.
| Field | Type | Source | Updated | Written by |
|---|---|---|---|---|
| id | string | calculated | never | database |
| Internal UUID primary key (distinct from Scryfall ids). | ||||
| scryfall_oracle_id | string | scryfall | on set release | scripts/seed-cards.ts |
| Scryfall oracle id — the stable per-card identity used for all external joins. | ||||
| name | string | scryfall | on set release | scripts/seed-cards.ts |
| Card name (front-face name for multi-face cards). | ||||
| mana_cost | string | null | scryfall | on set release | scripts/seed-cards.ts |
| Mana cost in brace notation, e.g. {2}{W}{U}. | ||||
| cmc | number | scryfall | on set release | scripts/seed-cards.ts |
| Mana value (converted mana cost). | ||||
| type_line | string | scryfall | on set release | scripts/seed-cards.ts |
| Full type line, e.g. 'Legendary Creature — Human Wizard'. | ||||
| oracle_text | string | null | scryfall | on set release | scripts/seed-cards.ts |
| Oracle rules text (front face for multi-face cards). | ||||
| colors | string[] | scryfall | on set release | scripts/seed-cards.ts |
| Card colors (WUBRG letters). | ||||
| color_identity | string[] | scryfall | on set release | scripts/seed-cards.ts |
| Commander color identity (WUBRG letters). | ||||
| keywords | string[] | scryfall | on set release | scripts/seed-cards.ts |
| Keyword abilities, e.g. Flying, Trample. | ||||
| produced_mana | string[] | null | scryfall | on set release | scripts/seed-cards.ts |
| Mana colors this card can produce, per Scryfall. | ||||
| layout | string | scryfall | on set release | scripts/seed-cards.ts |
| Scryfall layout, e.g. normal, transform, modal_dfc, adventure. | ||||
| legalities | Json | scryfall | on set release | scripts/seed-cards.ts |
| Per-format legality map (commander, modern, …). | ||||
| loyalty | string | null | scryfall | on set release | scripts/seed-cards.ts |
| Planeswalker starting loyalty (string; can be 'X'). | ||||
| power | string | null | scryfall | on set release | scripts/seed-cards.ts |
| Creature power (string; can be '*', 'X'). | ||||
| toughness | string | null | scryfall | on set release | scripts/seed-cards.ts |
| Creature toughness (string; can be '*', 'X'). | ||||
| defense | string | null | scryfall | on set release | scripts/seed-cards.ts |
| Battle defense value. | ||||
| rarity | string | null | scryfall | on set release | scripts/seed-cards.ts |
| Rarity of the representative printing. | ||||
| reserved | boolean | scryfall | on set release | scripts/seed-cards.ts |
| Reserved List membership. | ||||
| scryfall_uri | string | null | scryfall | on set release | scripts/seed-cards.ts |
| Canonical Scryfall page URL. | ||||
| source_hash | string | null | calculated | on set release | scripts/seed-cards.ts |
| Digest of the Scryfall fields describing this card, used to skip rows that have not changed. Excludes prices, image URLs and penny legality, each of which moves for reasons unrelated to the card. | ||||
| purchase_uris | Json | null | scryfall | on set release | scripts/seed-cards.ts |
| Vendor purchase URLs from Scryfall (TCGplayer etc.). | ||||
| all_parts | Json | null | scryfall | on set release | scripts/seed-cards.ts |
| Related card parts (tokens, meld pairs, adventures) from Scryfall. | ||||
| card_faces | Json | null | scryfall | on set release | scripts/seed-cards.ts |
| Per-face data for multi-face cards (names, texts, images). | ||||
| default_image_url | string | null | scryfall | on set release | scripts/seed-cards.ts |
| Representative card image URL (front face, normal size). | ||||
| card_types | string[] | null | calculated | on write | database |
| Main card types parsed from type_line (Creature, Instant, …). | ||||
| supertypes | string[] | null | calculated | on write | database |
| Supertypes parsed from type_line (Legendary, Basic, Snow, …). | ||||
| subtypes | string[] | null | calculated | on write | database |
| Subtypes parsed from type_line (Elf, Equipment, Aura, …); denormalized from card_subtypes. | ||||
| oracle_text_search | string | null | calculated | on write | database |
| GENERATED column concatenating oracle_text with all face texts for whole-card text search. | ||||
| embedding | string | null | ai | on demand | scripts/embed-cards.ts |
| Voyage voyage-3 embedding truncated to 256d, for pgvector re-ranking. | ||||
| tags | string[] | calculated | on write | database |
| Curated semantic tags (game_concepts vocabulary), denormalized from card_concept_associations by trigger. A concept a maintainer rejected is excluded whichever pass asserts it. | ||||
| embedding_stale | boolean | calculated | on write | database |
| Set when the trigger changes this card's tags, so the next embed:cards run refreshes the vector. Cleared as that run writes. | ||||
| set_codes | string[] | null | calculated | on set release | refresh_card_set_codes() SQL fn (after a printings seed) |
| Set codes this card's oracle has been printed in, denormalized from card_printings for the search set:/e: token. | ||||
| context_associations | string[] | null | ai | on demand | scripts/classify-cards-*.ts (tag pipeline) |
| Concept associations used to ground AI context resolution. | ||||
| leadership_skills | Json | null | mtgjson | on set release | scripts/ingest-mtgjson.ts (enrich) |
| MTGJSON leadershipSkills jsonb ({commander, brawl, oathbreaker, pauper_commander, predh}); NULL = no leadership data. | ||||
| has_alternative_deck_limit | boolean | null | mtgjson | on set release | scripts/ingest-mtgjson.ts (enrich) |
| Ignores the 1-copy deck limit (Relentless Rats etc.); NULL = no. | ||||
| game_changer | boolean | null | mtgjson | on set release | scripts/ingest-mtgjson.ts (enrich) |
| WotC Commander-brackets Game Changer list membership; NULL = no. | ||||
| edhrec_saltiness | number | null | mtgjson | on set release | scripts/ingest-mtgjson.ts (enrich) |
| EDHREC community saltiness score (0..1); NULL = unrated. | ||||
| created_at | string | calculated | never | database |
| Row creation timestamp. | ||||
| updated_at | string | calculated | on write | database |
| Last row update timestamp. | ||||
TypeScript model
interface cards {
id: string
scryfall_oracle_id: string
name: string
mana_cost: string | null
cmc: number
type_line: string
oracle_text: string | null
colors: string[]
color_identity: string[]
keywords: string[]
produced_mana: string[] | null
layout: string
legalities: Json
loyalty: string | null
power: string | null
toughness: string | null
defense: string | null
rarity: string | null
reserved: boolean
scryfall_uri: string | null
source_hash: string | null
purchase_uris: Json | null
all_parts: Json | null
card_faces: Json | null
default_image_url: string | null
card_types: string[] | null
supertypes: string[] | null
subtypes: string[] | null
oracle_text_search: string | null
embedding: string | null
tags: string[]
embedding_stale: boolean
set_codes: string[] | null
context_associations: string[] | null
leadership_skills: Json | null
has_alternative_deck_limit: boolean | null
game_changer: boolean | null
edhrec_saltiness: number | null
created_at: string
updated_at: string
}