Anki/rslib/src/storage/upgrades/schema15_upgrade.sql
2021-01-09 14:08:55 +10:00

43 lines
No EOL
1.2 KiB
SQL

CREATE TABLE FIELDS (
ntid integer NOT NULL,
ord integer NOT NULL,
name text NOT NULL COLLATE unicase,
config blob NOT NULL,
PRIMARY KEY (ntid, ord)
) without rowid;
CREATE UNIQUE INDEX idx_fields_name_ntid ON FIELDS (name, ntid);
CREATE TABLE templates (
ntid integer NOT NULL,
ord integer NOT NULL,
name text NOT NULL COLLATE unicase,
mtime_secs integer NOT NULL,
usn integer NOT NULL,
config blob NOT NULL,
PRIMARY KEY (ntid, ord)
) without rowid;
CREATE UNIQUE INDEX idx_templates_name_ntid ON templates (name, ntid);
CREATE INDEX idx_templates_usn ON templates (usn);
CREATE TABLE notetypes (
id integer NOT NULL PRIMARY KEY,
name text NOT NULL COLLATE unicase,
mtime_secs integer NOT NULL,
usn integer NOT NULL,
config blob NOT NULL
);
CREATE UNIQUE INDEX idx_notetypes_name ON notetypes (name);
CREATE INDEX idx_notetypes_usn ON notetypes (usn);
CREATE TABLE decks (
id integer PRIMARY KEY NOT NULL,
name text NOT NULL COLLATE unicase,
mtime_secs integer NOT NULL,
usn integer NOT NULL,
common blob NOT NULL,
kind blob NOT NULL
);
CREATE UNIQUE INDEX idx_decks_name ON decks (name);
CREATE INDEX idx_notes_mid ON notes (mid);
CREATE INDEX idx_cards_odid ON cards (odid)
WHERE odid != 0;
UPDATE col
SET ver = 15;
ANALYZE;