1
0

Separated initial data from db schema. Minor optimisations.

This commit is contained in:
2017-12-19 22:36:42 +01:00
parent ed7a847b90
commit 90c86f25f4
4 changed files with 106 additions and 109 deletions

86
sql/basedata.sql Normal file
View File

@ -0,0 +1,86 @@
PRAGMA journal_mode=WAL;
PRAGMA foreign_keys=on;
BEGIN TRANSACTION;
INSERT OR IGNORE INTO "families" VALUES (1, "KEYone");
INSERT OR IGNORE INTO "families" VALUES (2, "Motion");
INSERT OR IGNORE INTO "models" VALUES ( 1, 1, "BBB100-1");
INSERT OR IGNORE INTO "models" VALUES ( 2, 1, "BBB100-2");
INSERT OR IGNORE INTO "models" VALUES ( 3, 1, "BBB100-3");
INSERT OR IGNORE INTO "models" VALUES ( 4, 1, "BBB100-4/-5");
INSERT OR IGNORE INTO "models" VALUES ( 5, 1, "BBB100-6");
INSERT OR IGNORE INTO "models" VALUES ( 6, 1, "BBB100-7");
INSERT OR IGNORE INTO "models" VALUES ( 7, 2, "BBD100-1");
INSERT OR IGNORE INTO "models" VALUES ( 8, 2, "BBD100-2");
INSERT OR IGNORE INTO "models" VALUES ( 9, 2, "BBD100-6");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-001", 1, "Unlocked USA");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-003", 1, "Bell");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-005", 1, "Rogers");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-007", 1, "Telus");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-009", 1, "Hong Kong");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-010", 1, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-013", 1, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-017", 1, "Caribbean");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-020", 1, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-021", 1, "Hong Kong?");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-023", 1, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-024", 1, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-027", 1, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-029", 1, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-033", 1, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-036", 1, "AT&T");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-039", 1, "Black KEYone Canada");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-040", 1, "Black KEYone Malaysia");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-041", 1, "Black KEYone");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-042", 1, "Black KEYone");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-043", 1, "Black KEYone");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-044", 1, "Black KEYone Hong Kong");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-047", 1, "Black KEYone");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-051", 1, "Black KEYone");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63116-055", 1, "Black KEYone Korea");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-003", 2, "Unlocked UK");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-011", 2, "Unlocked EMEA");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-015", 2, "NL, Belgium");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-017", 2, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-019", 2, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-021", 2, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-023", 2, "AZERTY Belgium");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-025", 2, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-027", 2, "QWERTY UAE");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-028", 2, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-029", 2, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-034", 2, "UAE?");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-035", 2, "Black KEYone UK");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-036", 2, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-037", 2, "Black KEYone Middle East");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-039", 2, "Black KEYone Europe");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-040", 2, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-041", 2, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-042", 2, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-043", 2, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-044", 2, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-047", 2, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-703", 2, "Prerelease");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-704", 2, "Prerelease");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63117-717", 2, "Prerelease Black KEYone");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63118-001", 3, "Unlocked");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63118-003", 3, "Sprint");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63734-001", 4, "Unlocked -4");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63734-002", 4, "Unlocked -4");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63734-003", 4, "Unlocked -5");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63734-004", 4, "Unlocked -5");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63763-001", 5, "Unlocked");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63763-002", 5, "Unlocked Black KEYone");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63764-001", 6, "Unlocked");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63737-003", 7, "UK");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63737-007", 7, "Europe");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63737-009", 7, "Europe");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63739-009", 8, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63739-010", 8, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63753-002", 9, "");
INSERT OR IGNORE INTO "devices" VALUES ("PRD-63753-003", 9, "");
COMMIT;

View File

@ -3,111 +3,23 @@ PRAGMA foreign_keys=on;
CREATE TABLE "families" (
"familyId" INTEGER PRIMARY KEY AUTOINCREMENT,
"name" TEXT -- e.g. KEYone, Motion
"name" TEXT UNIQUE -- e.g. KEYone, Motion
);
-- Needs SQLite 3.7 or newer
INSERT INTO "families" ("name") VALUES
("KEYone"), -- familyId 1
("Motion") -- familyId 2
;
CREATE TABLE "models" (
"modelId" INTEGER PRIMARY KEY AUTOINCREMENT,
"familyId" INTEGER REFERENCES "families" ("familyId"),
"name" TEXT -- e.g. BBB100-1
"name" TEXT UNIQUE -- e.g. BBB100-1
);
-- Needs SQLite 3.7 or newer
INSERT INTO "models" ("familyId", "name") VALUES
(1, "BBB100-1"), -- modelId 1
(1, "BBB100-2"), -- modelId 2
(1, "BBB100-3"), -- modelId 3
(1, "BBB100-4/-5"), -- modelId 4
(1, "BBB100-6"), -- modelId 5
(1, "BBB100-7"), -- modelId 6
(2, "BBD100-1"), -- modelId 7
(2, "BBD100-2"), -- modelId 8
(2, "BBD100-6") -- modelId 9
;
CREATE TABLE "devices" (
"deviceId" INTEGER PRIMARY KEY AUTOINCREMENT,
"ref" TEXT, -- PRD number
"curef" TEXT UNIQUE PRIMARY KEY, -- PRD number
"modelId" INTEGER REFERENCES "models" ("modelId"),
"name" TEXT -- e.g. Unlocked USA, Black KEYone
);
-- Needs SQLite 3.7 or newer
INSERT INTO "devices" ("ref", "modelId", "name") VALUES
("PRD-63116-001", 1, "Unlocked USA"),
("PRD-63116-003", 1, "Bell"),
("PRD-63116-005", 1, "Rogers"),
("PRD-63116-007", 1, "Telus"),
("PRD-63116-009", 1, "Hong Kong"),
("PRD-63116-010", 1, ""),
("PRD-63116-013", 1, ""),
("PRD-63116-017", 1, "Caribbean"),
("PRD-63116-020", 1, ""),
("PRD-63116-021", 1, "Hong Kong?"),
("PRD-63116-023", 1, ""),
("PRD-63116-024", 1, ""),
("PRD-63116-027", 1, ""),
("PRD-63116-029", 1, ""),
("PRD-63116-033", 1, ""),
("PRD-63116-036", 1, "AT&T"),
("PRD-63116-039", 1, "Black KEYone Canada"),
("PRD-63116-040", 1, "Black KEYone Malaysia"),
("PRD-63116-041", 1, "Black KEYone"),
("PRD-63116-042", 1, "Black KEYone"),
("PRD-63116-043", 1, "Black KEYone"),
("PRD-63116-044", 1, "Black KEYone Hong Kong"),
("PRD-63116-047", 1, "Black KEYone"),
("PRD-63116-051", 1, "Black KEYone"),
("PRD-63116-055", 1, "Black KEYone Korea"),
("PRD-63117-003", 2, "Unlocked UK"),
("PRD-63117-011", 2, "Unlocked EMEA"),
("PRD-63117-015", 2, "NL, Belgium"),
("PRD-63117-017", 2, ""),
("PRD-63117-019", 2, ""),
("PRD-63117-021", 2, ""),
("PRD-63117-023", 2, "AZERTY Belgium"),
("PRD-63117-025", 2, ""),
("PRD-63117-027", 2, "QWERTY UAE"),
("PRD-63117-028", 2, ""),
("PRD-63117-029", 2, ""),
("PRD-63117-034", 2, "UAE?"),
("PRD-63117-035", 2, "Black KEYone UK"),
("PRD-63117-036", 2, ""),
("PRD-63117-037", 2, "Black KEYone Middle East"),
("PRD-63117-039", 2, "Black KEYone Europe"),
("PRD-63117-040", 2, ""),
("PRD-63117-041", 2, ""),
("PRD-63117-042", 2, ""),
("PRD-63117-043", 2, ""),
("PRD-63117-044", 2, ""),
("PRD-63117-047", 2, ""),
("PRD-63117-703", 2, "Prerelease"),
("PRD-63117-704", 2, "Prerelease"),
("PRD-63117-717", 2, "Prerelease Black KEYone"),
("PRD-63118-001", 3, "Unlocked"),
("PRD-63118-003", 3, "Sprint"),
("PRD-63734-001", 4, "Unlocked -4"),
("PRD-63734-002", 4, "Unlocked -4"),
("PRD-63734-003", 4, "Unlocked -5"),
("PRD-63734-004", 4, "Unlocked -5"),
("PRD-63763-001", 5, "Unlocked"),
("PRD-63763-002", 5, "Unlocked Black KEYone"),
("PRD-63764-001", 6, "Unlocked"),
("PRD-63737-003", 7, "UK"),
("PRD-63737-007", 7, "Europe"),
("PRD-63737-009", 7, "Europe"),
("PRD-63739-009", 8, ""),
("PRD-63739-010", 8, ""),
("PRD-63753-002", 9, ""),
("PRD-63753-003", 9, "")
;
-- we only care about the first file for now
CREATE TABLE "files" (
"sha1" TEXT UNIQUE PRIMARY KEY, -- checksum of file
"file_name" TEXT, -- filename of file
@ -120,8 +32,6 @@ CREATE TABLE "files" (
"published_last" INTEGER -- stamp of latest pubdate
);
-- we only care about the first file for now
-- a separate "files" table might get introduced later
CREATE TABLE "updates" (
"updateId" INTEGER PRIMARY KEY AUTOINCREMENT,
"curef" TEXT, -- PRD number