Add table indexes

This commit is contained in:
Correl Roush 2021-12-18 21:42:11 -05:00
parent 0140c9c889
commit 0f0abcd66e

View file

@ -1,12 +1,3 @@
CREATE TABLE IF NOT EXISTS `copies` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`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` ( CREATE TABLE IF NOT EXISTS `cards` (
`scryfall_id` TEXT PRIMARY KEY, `scryfall_id` TEXT PRIMARY KEY,
`name` TEXT NOT NULL, `name` TEXT NOT NULL,
@ -24,6 +15,20 @@ CREATE TABLE IF NOT EXISTS `cards` (
`oracle_text` TEXT `oracle_text` TEXT
); );
CREATE INDEX `cards_name` ON `cards`(`name` COLLATE nocase);
CREATE INDEX `cards_rarity` ON `cards`(`rarity`);
CREATE INDEX `cards_color_identity` ON `cards`(`color_identity`);
CREATE TABLE IF NOT EXISTS `copies` (
`id` INTEGER PRIMARY KEY AUTOINCREMENT,
`collection` TEXT NOT NULL DEFAULT 'Default',
`scryfall_id` TEXT,
`isFoil` INTEGER NOT NULL DEFAULT 0,
`language` TEXT,
`condition` TEXT,
FOREIGN KEY (`scryfall_id`) REFERENCES `cards`(`scryfall_id`)
);
CREATE TABLE IF NOT EXISTS `card_prices` ( CREATE TABLE IF NOT EXISTS `card_prices` (
`scryfall_id` TEXT, `scryfall_id` TEXT,
`date` TEXT, `date` TEXT,
@ -32,7 +37,8 @@ CREATE TABLE IF NOT EXISTS `card_prices` (
`eur` TEXT, -- Decimal value `eur` TEXT, -- Decimal value
`eur_foil` TEXT, -- Decimal value `eur_foil` TEXT, -- Decimal value
`tix` TEXT, -- Decimal value `tix` TEXT, -- Decimal value
PRIMARY KEY (`scryfall_id`, `date`) PRIMARY KEY (`scryfall_id`, `date`),
FOREIGN KEY (`scryfall_id`) REFERENCES `cards`(`scryfall_id`)
); );
CREATE TABLE IF NOT EXISTS `sets` ( CREATE TABLE IF NOT EXISTS `sets` (