From 271d8202de99a3629424f06558849d256477f0eb Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sun, 11 Aug 2024 21:14:48 +0800 Subject: [PATCH] Create index for pmeta (token) --- db.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/db.ts b/db.ts index 4f5b1a2..e7d7106 100644 --- a/db.ts +++ b/db.ts @@ -268,6 +268,7 @@ const PMETA_TABLE = `CREATE TABLE pmeta ( height INT, PRIMARY KEY (gid, "index") );`; +const PMETA_INDEX = `CREATE INDEX pmeta_token ON pmeta (token);`; const TAG_TABLE = `CREATE TABLE tag ( id INTEGER PRIMARY KEY AUTOINCREMENT, tag TEXT, @@ -355,7 +356,7 @@ export class EhDb { #base_path: string; #db_path: string; #use_ffi = false; - readonly version = parse_ver("1.0.0-13"); + readonly version = parse_ver("1.0.0-14"); constructor(base_path: string) { this.#base_path = base_path; this.#db_path = join(base_path, "data.db"); @@ -515,6 +516,9 @@ export class EhDb { this.db.execute("ALTER TABLE token ADD client_version TEXT;"); this.db.execute("ALTER TABLE token ADD client_platform TEXT;"); } + if (compare_ver(v, parse_ver("1.0.0-14")) === -1) { + this.db.execute(PMETA_INDEX); + } this.#write_version(); if (need_optimize) this.optimize(); }