SQlite error: tables are not created
rubenmdh opened this issue ยท 7 comments
Hello,
I am trying to install lolisafe in production mode and for some reason lolisafe doesn't generate the database tables at all.
I've followed the six steps specified in the readme.md but as soon as I try to start it the following error is shown:
~/lolisafe# yarn start
yarn run v1.19.1
$ node ./lolisafe.js
[2019-10-21 11:42:38] { [Error: SQLITE_ERROR: no such table: files] errno: 1, code: 'SQLITE_ERROR' }
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I've tried both with an unprivileged user and with root, both fail, so this is not a permissions issue. "ls" to the database directory shows the db file as 0 bytes.
This is on a Debian Buster installation within a LXC container with a recent kernel. I am using the nodejs version available in Buster repositories (v10.15.2)
Ah yes, sorry about that.
The main script lolisafe.js
doesn't wait for DB tables to be created first, before proceeding to query the tables (for file identifiers cache and whatnot). And since it exits immediately upon error, the database is never fully initiated.
Meanwhile, try to delete any leftover, and possibly broken anyway, db file with rm database/db
in lolisafe's root dir.
Then you can try to run node
to start node shell, also in lolisafe's root dir, and then execute the commands below through it:
require('./database/db.js')(require('knex')({ client: 'sqlite3', connection: { filename: './database/db' }, useNullAsDefault: true }))
That should properly initiate the sqlite databse with all the required tables and whatnot.
I'll commit a permanent fix in a few hours. Thanks for the report! ๐
Thank you for your fast response. After following the instructions you gave me, it works flawlessly.
Thank you for mantaining this fork, I've been using it for quite a while now and it is just awesome.
I will close this issue now as the commit will roll out soon.
I have to reopen this as I can't log in to the root account.
I've checked that the default admin details should be as follow:
Username: root
Password: changeme
I am unable to log in with these details. Do I have to initialize the root account somehow?
Ah, if your DB was created BEFORE the bug fix commit (that is, through the instructions I sent previously), the default login was username root
& password root
.
But I forgot that a couple weeks ago, I enforced password min length to 6 chars in the auth page, thus preventing new installations from using root
password (cause it's only 4 chars).
So I decided to also change the default password in that bug fix commit to changeme
, but that will only apply to new DB created AFTER the commit.
If necessary, you can execute the commands below in node
shell to forcefully update the admin account's password (if starting over with a clean DB is not an option):
db = require('knex')({ client: 'sqlite3', connection: { filename: './database/db' }, useNullAsDefault: true })
require('bcrypt').hash('changeme', 10).then(pass => db.table('users').where('username', 'root').first().update('password', pass))
Make sure to execute the command line by line.
It'll update the password to changeme
.
If necessary, you can execute the commands below in
node
shell to forcefully update the admin account's password (if starting over with a clean DB is not an option):db = require('knex')({ client: 'sqlite3', connection: { filename: './database/db' }, useNullAsDefault: true }) require('bcrypt').hash('changeme', 10).then(pass => db.table('users').where('username', 'root').first().update('password', pass))Make sure to execute the command line by line.
It'll update the password tochangeme
.
Thanks for the help, I just logged in changing the minlength value from the password box to 4. This works for logging in although it doesn't for registering, which is the expected scenario.
Feel free to close this issue if everything seems ok to you.
Aha, I had the impression that I also forced the min length on the login API, which was why I didn't bother to suggest temporarily editing the input's minlength attribute.
I guess it wouldn't make much sense to force it on the API to begin with, so I'll leave it as it is.
Anyway, good to know it's working for you ๐