summaryrefslogtreecommitdiffstats
path: root/pyload/database/DatabaseBackend.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2014-01-18 18:45:13 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2014-01-18 18:45:13 +0100
commit453c1e55c71a96c9529ecdca1d55278cc41088d6 (patch)
tree7a516a84e5590ce5f1f3def71c24bcb14f209023 /pyload/database/DatabaseBackend.py
parentsmall fixes and improvements for download engine (diff)
downloadpyload-453c1e55c71a96c9529ecdca1d55278cc41088d6.tar.xz
rewritten download scheduling, improved account manager, db version increased all data will be overwritten
Diffstat (limited to 'pyload/database/DatabaseBackend.py')
-rw-r--r--pyload/database/DatabaseBackend.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/pyload/database/DatabaseBackend.py b/pyload/database/DatabaseBackend.py
index df8c6e704..1bdcdc582 100644
--- a/pyload/database/DatabaseBackend.py
+++ b/pyload/database/DatabaseBackend.py
@@ -30,7 +30,7 @@ except:
import sqlite3
DB = None
-DB_VERSION = 6
+DB_VERSION = 7
def set_DB(db):
@@ -298,6 +298,7 @@ class DatabaseBackend(Thread):
)
self.c.execute('CREATE INDEX IF NOT EXISTS "file_index" ON files(package, owner)')
self.c.execute('CREATE INDEX IF NOT EXISTS "file_owner" ON files(owner)')
+ self.c.execute('CREATE INDEX IF NOT EXISTS "file_plugin" ON files(plugin)')
self.c.execute(
'CREATE TRIGGER IF NOT EXISTS "insert_file" AFTER INSERT ON "files"'
@@ -366,30 +367,32 @@ class DatabaseBackend(Thread):
self.c.execute(
'CREATE TABLE IF NOT EXISTS "accounts" ('
+ '"aid" INTEGER PRIMARY KEY AUTOINCREMENT, '
'"plugin" TEXT NOT NULL, '
'"loginname" TEXT NOT NULL, '
- '"owner" INTEGER NOT NULL DEFAULT -1, '
+ '"owner" INTEGER NOT NULL, '
'"activated" INTEGER NOT NULL DEFAULT 1, '
'"password" TEXT DEFAULT "", '
'"shared" INTEGER NOT NULL DEFAULT 0, '
'"options" TEXT DEFAULT "", '
- 'FOREIGN KEY(owner) REFERENCES users(uid), '
- 'PRIMARY KEY (plugin, loginname, owner) ON CONFLICT REPLACE'
+ 'FOREIGN KEY(owner) REFERENCES users(uid)'
')'
)
+ self.c.execute('CREATE INDEX IF NOT EXISTS "accounts_login" ON accounts(plugin, loginname)')
+
self.c.execute(
'CREATE TABLE IF NOT EXISTS "stats" ('
+ '"id" INTEGER PRIMARY KEY AUTOINCREMENT, '
'"user" INTEGER NOT NULL, '
'"plugin" TEXT NOT NULL, '
'"time" INTEGER NOT NULL, '
'"premium" INTEGER DEFAULT 0 NOT NULL, '
'"amount" INTEGER DEFAULT 0 NOT NULL, '
- 'FOREIGN KEY(user) REFERENCES users(uid), '
- 'PRIMARY KEY(user, plugin, time)'
+ 'FOREIGN KEY(user) REFERENCES users(uid)'
')'
)
- self.c.execute('CREATE INDEX IF NOT EXISTS "stats_time" ON stats(time)')
+ self.c.execute('CREATE INDEX IF NOT EXISTS "stats_time" ON stats(user, time)')
#try to lower ids
self.c.execute('SELECT max(fid) FROM files')