diff options
author | Andinus <andinus@nand.sh> | 2020-03-27 14:38:31 +0530 |
---|---|---|
committer | Andinus <andinus@nand.sh> | 2020-03-27 16:47:59 +0530 |
commit | f22adf24e886cf4382a26b4777c5b481b21c26f5 (patch) | |
tree | 6c4b05febceaeddd9f6f63373349397422723f9d /storage | |
parent | 5d65b69f75d9d812a04b816630295b2169da864b (diff) | |
download | perseus-f22adf24e886cf4382a26b4777c5b481b21c26f5.tar.gz |
Change database schema
Diffstat (limited to 'storage')
-rw-r--r-- | storage/sqlite3/init.go | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/storage/sqlite3/init.go b/storage/sqlite3/init.go index ffdc6b9..e79d3ff 100644 --- a/storage/sqlite3/init.go +++ b/storage/sqlite3/init.go @@ -41,32 +41,21 @@ func Init(db *DB) { } sqlstmt := []string{ - // Create users table, this will hold information on - // account like id, type & other user specific - // information. We are using id because later we may - // want to add username change or account delete - // functionality. username here is not unique because - // if user deletes account then we'll change it to - // "ghost" or something. This doesn't mean usernames - // shouldn't be unique, registration table requires - // them to be unique so it'll fail if they aren't - // unique. - `CREATE TABLE IF NOT EXISTS users ( - id TEXT PRIMARY KEY, - type TEXT NOT NULL DEFAULT notadmin, - username TEXT NOT NULL, - password TEXT NOT NULL);`, + // Users can login with multiple devices and so + // multiple tokens will be created. This shouldn't be + // used for login, logins should be verified with + // users table only. + `CREATE TABLE IF NOT EXISTS access ( + id TEXT NOT NULL, + token TEXT NOT NULL, + genTime TEXT NOT NULL);`, - // Create registration table, this will hold user - // account details like registration time, ip & - // similar details. This is the only place that will - // relate the username to id even after deletion. - // usernames must be unique in this table. - `CREATE TABLE IF NOT EXISTS registration ( + `CREATE TABLE IF NOT EXISTS users ( id TEXT PRIMARY KEY, - username TEXT NOT NULL UNIQUE, - reg_time TEXT NOT NULL, - reg_ip TEXT NOT NULL);`, + type TEXT NOT NULL DEFAULT user, + username VARCHAR(128) NOT NULL UNIQUE, + password TEXT NOT NULL, + regTime TEXT NOT NULL);`, } // We range over statements and execute them one by one, this |