2017-11-01 17:47:41 +00:00
|
|
|
PRAGMA journal_mode=WAL;
|
|
|
|
PRAGMA foreign_keys=on;
|
|
|
|
|
|
|
|
CREATE TABLE "families" (
|
|
|
|
"familyId" INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
|
|
"name" TEXT -- e.g. KEYone, Motion
|
|
|
|
);
|
|
|
|
|
|
|
|
-- Needs SQLite 3.7 or newer
|
|
|
|
INSERT INTO "families" ("name") VALUES
|
|
|
|
("KEYone"),
|
|
|
|
("Motion")
|
|
|
|
;
|
|
|
|
|
|
|
|
CREATE TABLE "models" (
|
|
|
|
"modelId" INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
|
|
"familyId" INTEGER REFERENCES "families" ("familyId"),
|
|
|
|
"name" TEXT -- e.g. BBB100-1
|
|
|
|
);
|
|
|
|
|
2017-11-01 18:26:42 +00:00
|
|
|
-- Needs SQLite 3.7 or newer
|
2017-11-01 23:05:39 +00:00
|
|
|
INSERT INTO "models" ("familyId", "name") VALUES
|
|
|
|
(1, "BBB100-1"),
|
|
|
|
(1, "BBB100-2"),
|
|
|
|
(2, "BBD100-1")
|
2017-11-01 17:47:41 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
CREATE TABLE "devices" (
|
|
|
|
"deviceId" INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
|
|
"ref" TEXT, -- PRD number
|
|
|
|
"modelId" INTEGER REFERENCES "models" ("modelId"),
|
|
|
|
"name" TEXT -- e.g. Unlocked USA, Black KEYone
|
|
|
|
);
|
|
|
|
|
2017-11-01 18:26:42 +00:00
|
|
|
-- Needs SQLite 3.7 or newer
|
2017-11-01 23:05:39 +00:00
|
|
|
INSERT INTO "devices" ("ref", "modelId", "name") VALUES
|
|
|
|
("PRD-63117-011", 2, "Unlocked EMEA"),
|
|
|
|
("PRD-63116-001", 1, "Unlocked USA")
|
2017-11-01 17:47:41 +00:00
|
|
|
;
|
|
|
|
|
2017-12-11 01:40:07 +00:00
|
|
|
CREATE TABLE "files" (
|
|
|
|
"sha1" TEXT UNIQUE PRIMARY KEY, -- checksum of file
|
|
|
|
"file_name" TEXT, -- filename of file
|
|
|
|
"file_size" INTEGER, -- size
|
|
|
|
"type" TEXT, -- FULL(4) or OTA(2) update
|
|
|
|
"note" TEXT, -- description of file (optional)
|
|
|
|
"published_first" INTEGER, -- stamp of earliest pubdate
|
|
|
|
"published_last" INTEGER -- stamp of latest pubdate
|
|
|
|
);
|
|
|
|
|
2017-11-01 18:26:42 +00:00
|
|
|
-- we only care about the first file for now
|
|
|
|
-- a separate "files" table might get introduced later
|
2017-11-01 17:55:32 +00:00
|
|
|
CREATE TABLE "updates" (
|
|
|
|
"updateId" INTEGER PRIMARY KEY AUTOINCREMENT,
|
2017-11-01 18:26:42 +00:00
|
|
|
"tv" TEXT, -- target version, e.g. AAQ302
|
|
|
|
"fv" TEXT, -- from version (only for OTA)
|
|
|
|
"svn" TEXT, -- version info from <SVN> field
|
|
|
|
"pubDate" INTEGER, -- published date
|
|
|
|
"publisher" TEXT, -- publisher
|
2017-11-03 23:56:55 +00:00
|
|
|
"fwId" TEXT, -- <FW_ID> (CHANGES FOR THE SAME FILE_ID!!!) MAYBE MOVE TO update_map
|
2017-11-01 18:26:42 +00:00
|
|
|
"file_id" TEXT, -- <FILE_ID> of first file
|
2017-12-11 01:40:07 +00:00
|
|
|
"file_sha1" TEXT -- SHA1 checksum of first file
|
2017-11-01 17:47:41 +00:00
|
|
|
);
|
2017-12-11 00:28:52 +00:00
|
|
|
CREATE UNIQUE INDEX "index_updates" ON "updates" (
|
|
|
|
"tv",
|
|
|
|
"fv",
|
|
|
|
"fwId",
|
|
|
|
"file_id"
|
|
|
|
);
|
2017-11-01 17:47:41 +00:00
|
|
|
|
2017-11-01 17:55:32 +00:00
|
|
|
-- Maps update files to devices
|
|
|
|
CREATE TABLE "update_map" (
|
|
|
|
"deviceId" INTEGER REFERENCES "devices" ("deviceId"),
|
2017-11-03 23:56:55 +00:00
|
|
|
"updateId" INTEGER REFERENCES "updates" ("updateId"),
|
|
|
|
"seenDate" INTEGER -- timestamp when this record was added
|
2017-11-01 17:55:32 +00:00
|
|
|
);
|