1
0
mirror of https://github.com/mbirth/tcl_update_db.git synced 2024-12-26 12:34:07 +00:00

Move fv and tv into files table.

This commit is contained in:
Markus Birth 2017-12-12 01:51:18 +01:00
parent c675eeacbf
commit 6d8f3bda7b
Signed by: mbirth
GPG Key ID: A9928D7A098C3A9A
2 changed files with 8 additions and 7 deletions

View File

@ -14,6 +14,7 @@ class SQLiteWriter
if ($this->pdo === false) {
return $sqlerror;
}
$this->pdo->exec('PRAGMA foreign_keys=on;');
}
private function insertArray($table, $data, $replace = false)
@ -75,6 +76,8 @@ class SQLiteWriter
'sha1' => $file_arr['file_sha1'],
'file_name' => $file_arr['file_name'],
'file_size' => $file_arr['file_size'],
'fv' => $file_arr['fv'],
'tv' => $file_arr['tv'],
'type' => $file_arr['type'],
'note' => json_encode($note, JSON_UNESCAPED_UNICODE),
'published_first' => $pubFirst,
@ -90,6 +93,8 @@ class SQLiteWriter
'file_name' => $g->filename,
'file_size' => $g->file_size,
'type' => $g->type,
'fv' => $g->fv,
'tv' => $g->tv,
'note' => array(
'en' => $g->description_en,
'ja' => $g->description_ja,
@ -98,8 +103,6 @@ class SQLiteWriter
'pubDate' => $g->time,
));
$ok = $this->insertArray('updates', array(
'tv' => $g->tv,
'fv' => $g->fv,
'svn' => $g->svn,
'pubDate' => $g->time,
'publisher' => $g->publisher,

View File

@ -43,6 +43,8 @@ CREATE TABLE "files" (
"file_name" TEXT, -- filename of file
"file_size" INTEGER, -- size
"type" TEXT, -- FULL(4) or OTA(2) update
"fv" TEXT, -- from version (only for OTA)
"tv" TEXT, -- target version, e.g. AAQ302
"note" TEXT, -- description of file (optional)
"published_first" INTEGER, -- stamp of earliest pubdate
"published_last" INTEGER -- stamp of latest pubdate
@ -52,18 +54,14 @@ CREATE TABLE "files" (
-- a separate "files" table might get introduced later
CREATE TABLE "updates" (
"updateId" INTEGER PRIMARY KEY AUTOINCREMENT,
"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
"fwId" TEXT, -- <FW_ID> (CHANGES FOR THE SAME FILE_ID!!!) MAYBE MOVE TO update_map
"file_id" TEXT, -- <FILE_ID> of first file
"file_sha1" TEXT -- SHA1 checksum of first file
"file_sha1" TEXT REFERENCES "files" ("sha1") -- SHA1 checksum of first file
);
CREATE UNIQUE INDEX "index_updates" ON "updates" (
"tv",
"fv",
"fwId",
"file_id"
);