summaryrefslogtreecommitdiffstats
path: root/module/database/DatabaseBackend.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-05-06 20:40:39 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-05-06 20:40:39 +0200
commit3d7ed0c367cf521b61ec1f78784dec73a3b7c32a (patch)
treedad3965d15ce1f462ab85f9f2f5a7e4e0399eae6 /module/database/DatabaseBackend.py
parentconcept for multiuser api (diff)
downloadpyload-3d7ed0c367cf521b61ec1f78784dec73a3b7c32a.tar.xz
some classes for multi user mode
Diffstat (limited to 'module/database/DatabaseBackend.py')
-rw-r--r--module/database/DatabaseBackend.py31
1 files changed, 27 insertions, 4 deletions
diff --git a/module/database/DatabaseBackend.py b/module/database/DatabaseBackend.py
index 18898a93c..6373120ff 100644
--- a/module/database/DatabaseBackend.py
+++ b/module/database/DatabaseBackend.py
@@ -322,13 +322,36 @@ class DatabaseBackend(Thread):
self.c.execute(
'CREATE TABLE IF NOT EXISTS "users" ('
- '"name" TEXT PRIMARY KEY NOT NULL, '
+ '"id" INTEGER PRIMARY KEY AUTOINCREMENT, '
+ '"name" TEXT NOT NULL, '
'"email" TEXT DEFAULT "" NOT NULL, '
'"password" TEXT NOT NULL, '
'"role" INTEGER DEFAULT 0 NOT NULL, '
'"permission" INTEGER DEFAULT 0 NOT NULL, '
'"folder" TEXT DEFAULT "" NOT NULL, '
- '"template" TEXT DEFAULT "default" NOT NULL'
+ '"ratio" INTEGER DEFAULT -1 NOT NULL, '
+ '"limit" INTEGER DEFAULT -1 NOT NULL, '
+ '"template" TEXT DEFAULT "default" NOT NULL, '
+ '"user" INTEGER DEFAULT -1 NOT NULL, '
+ 'FOREIGN KEY(user) REFERENCES users(id)'
+ ')'
+ )
+
+ self.c.execute(
+ 'CREATE TRIGGER IF NOT EXISTS "insert_user" AFTER INSERT ON "users"'
+ 'BEGIN '
+ 'UPDATE users SET user = new.id '
+ 'WHERE rowid = new.rowid;'
+ 'END'
+ )
+
+ self.c.execute(
+ 'CREATE TABLE IF NOT EXISTS "settings" ('
+ '"plugin" TEXT NOT NULL, '
+ '"owner" INTEGER NOT NULL, '
+ '"configuration" TEXT NOT NULL, '
+ 'FOREIGN KEY(owner) REFERENCES users(id), '
+ 'PRIMARY KEY (plugin, owner) ON CONFLICT REPLACE'
')'
)
@@ -339,8 +362,8 @@ class DatabaseBackend(Thread):
'"activated" INTEGER DEFAULT 1, '
'"password" TEXT DEFAULT "", '
'"options" TEXT DEFAULT "", '
-# '"user" TEXT NOT NULL, '
-# 'FOREIGN KEY(user) REFERENCES users(name)'
+# '"owner" INTEGER NOT NULL, ' TODO: shared, owner attribute
+# 'FOREIGN KEY(owner) REFERENCES users(id)'
'PRIMARY KEY (plugin, loginname) ON CONFLICT REPLACE'
')'
)