tutor/tables.sql

65 lines
1.7 KiB
MySQL
Raw Normal View History

2021-07-05 22:23:08 +00:00
CREATE TABLE IF NOT EXISTS `copies` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
2021-07-07 18:59:32 +00:00
`collection` TEXT NOT NULL DEFAULT 'Default',
`scryfall_id` TEXT,
`isFoil` INTEGER NOT NULL DEFAULT 0,
`language` TEXT,
`condition` TEXT
);
CREATE TABLE IF NOT EXISTS `cards` (
`scryfall_id` TEXT PRIMARY KEY,
`name` TEXT NOT NULL,
`set_code` TEXT NOT NULL,
`collector_number` TEXT NOT NULL,
2021-07-07 18:59:32 +00:00
`release_date` TEXT NOT NULL,
`rarity` TEXT NOT NULL,
`color_identity` TEXT NOT NULL,
2021-07-07 18:59:32 +00:00
`cmc` TEXT NOT NULL, -- Decimal value
`type_line` TEXT NOT NULL,
`foil` INTEGER NOT NULL DEFAULT 0,
`nonfoil` INTEGER NOT NULL DEFAULT 1,
2021-07-07 18:59:32 +00:00
`variation` INTEGER NOT NULL DEFAULT 0,
`edhrec_rank` INTEGER,
`oracle_text` TEXT
);
CREATE TABLE IF NOT EXISTS `sets` (
`set_code` TEXT PRIMARY KEY,
`name` TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS `rarities` (
`rarity` TEXT PRIMARY KEY,
`rarity_ord` INTEGER NOT NULL
);
DELETE FROM `rarities`;
INSERT INTO `rarities` (`rarity`, `rarity_ord`) VALUES
('common', 1),
('uncommon', 2),
('rare', 3),
('special', 4),
('mythic', 5),
('bonus', 6);
2021-07-07 18:59:32 +00:00
CREATE TABLE IF NOT EXISTS `legalities` (
`scryfall_id` TEXT NOT NULL,
`format` TEXT NOT NULL,
`legality` TEXT NOT NULL,
PRIMARY KEY (`scryfall_id`, `format`),
FOREIGN KEY (`scryfall_id`) REFERENCES `cards`(`scryfall_id`)
);
CREATE TABLE IF NOT EXISTS `games` (
`scryfall_id` TEXT NOT NULL,
`game` TEXT NOT NULL, -- 'paper', 'arena', or 'mtgo'
PRIMARY KEY (`scryfall_id`, `game`),
FOREIGN KEY (`scryfall_id`) REFERENCES `cards`(`scryfall_id`)
);
CREATE TABLE IF NOT EXISTS `vars` (
`key` TEXT PRIMARY KEY,
`value` TEXT
2021-07-05 22:23:08 +00:00
);