-- V1: maps tagging + used_in_quest flag
PRAGMA foreign_keys = ON;

CREATE TABLE IF NOT EXISTS maps (
  id INTEGER PRIMARY KEY,
  name TEXT UNIQUE
);

CREATE TABLE IF NOT EXISTS key_maps (
  key_id INTEGER NOT NULL,
  map_id INTEGER NOT NULL,
  PRIMARY KEY (key_id, map_id),
  FOREIGN KEY (key_id) REFERENCES keys(id),
  FOREIGN KEY (map_id) REFERENCES maps(id)
);

ALTER TABLE key_ratings ADD COLUMN used_in_quest INTEGER DEFAULT 0;

INSERT OR IGNORE INTO maps (name) VALUES
  ('Customs'),
  ('Factory'),
  ('Shoreline'),
  ('Interchange'),
  ('Reserve'),
  ('Woods'),
  ('Labs'),
  ('Streets');
