create indices in magneticow rather than magneticod (rationale below)

It's better to create indices in magneticow rather than magneticod,
because magneticod does NOT need them, but magneticow does.
This commit is contained in:
Bora M. Alper 2017-06-16 12:08:30 +03:00
parent c4b4773fdd
commit e624837059
2 changed files with 2 additions and 2 deletions

View File

@ -50,14 +50,12 @@ class Database:
"total_size INTEGER NOT NULL CHECK(total_size > 0),"
"discovered_on INTEGER NOT NULL CHECK(discovered_on > 0)"
");")
db_conn.execute("CREATE INDEX IF NOT EXISTS info_hash_index ON torrents (info_hash);")
db_conn.execute("CREATE TABLE IF NOT EXISTS files ("
"id INTEGER PRIMARY KEY,"
"torrent_id INTEGER REFERENCES torrents ON DELETE CASCADE ON UPDATE RESTRICT,"
"size INTEGER NOT NULL,"
"path TEXT NOT NULL"
");")
db_conn.execute("CREATE INDEX IF NOT EXISTS file_info_hash_index ON files (torrent_id);")
return db_conn

View File

@ -322,6 +322,8 @@ def initialize_magneticod_db() -> None:
magneticod_db.execute("PRAGMA journal_mode=WAL;")
magneticod_db.execute("CREATE INDEX IF NOT EXISTS discovered_on_index ON torrents (discovered_on);")
magneticod_db.execute("CREATE INDEX IF NOT EXISTS info_hash_index ON torrents (info_hash);")
magneticod_db.execute("CREATE INDEX IF NOT EXISTS file_info_hash_index ON files (torrent_id);")
magneticod_db.execute("CREATE VIRTUAL TABLE temp.fts_torrents USING fts4(name);")
magneticod_db.execute("INSERT INTO fts_torrents (docid, name) SELECT id, name FROM torrents;")