New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"No such table: users" on fresh SQLite instance #59

Closed
MasterGroosha opened this Issue Jan 8, 2019 · 6 comments

Comments

Projects
None yet
3 participants
@MasterGroosha
Copy link

MasterGroosha commented Jan 8, 2019

Describe the bug

When creating a new instance of Writefreely with SQLite backend, writefreely --config command asks for admin's username and password, however on this step no schema is imported yet, which leads to

2019/01/08 07:46:07 Connecting to sqlite3 database...
2019/01/08 07:46:07 Creating user {MY_USER}...
ERROR: 2019/01/08 07:46:07 log.go:26: Rolling back users INSERT: no such table: users
ERROR: 2019/01/08 07:46:07 log.go:26: Unable to create user: no such table: users

After this error I had to run writefreely --init-db and then repeat writefreely --config to successfully finish my blog setup.

Expected behavior

When using SQLite backend, schema import should be done automatically, since there's no pre-built database like MySQL

Application configuration

  • Single mode or Multi-user mode? Single mode
  • Database? [mysql/sqlite] SQLite
  • Open registration? [yes/no] No
  • Federation enabled? [yes/no] Yes

Version or last commit: 0.7.0

@geekgonecrazy

This comment has been minimized.

Copy link
Contributor

geekgonecrazy commented Jan 8, 2019

I’m now recalling this happening to me to. It seems that in SQLite it creates user in that step where as MySQL it doesn’t. Maybe easiest is to not create user automatically in this step and keep it the same for both SQLite and MySQL?

@MasterGroosha

This comment has been minimized.

Copy link

MasterGroosha commented Jan 8, 2019

@geekgonecrazy is it safe to move admin account creation to "init db" step?

@geekgonecrazy

This comment has been minimized.

Copy link
Contributor

geekgonecrazy commented Jan 8, 2019

Nvm I was mistaken. Looks like if you choose single user mode it does try to insert the user.

https://github.com/writeas/writefreely/blob/v0.7.0/config/setup.go#L246
https://github.com/writeas/writefreely/blob/v0.7.0/app.go#L228

So either needs to not do that... or try to do the schema step in addition.

@thebaer

This comment has been minimized.

Copy link
Member

thebaer commented Jan 8, 2019

@MasterGroosha Moving account creation to --init-db is a good thought, but I think that command should remain non-interactive, so doing it there probably wouldn't be a good fit.

I guess we have to decide what the --config step should be. Should that command stay as a utility you can repeatedly run? Or should it be more of an install step that guides the user as much as possible? I'm thinking the latter (in which case we'd include the init-db step), but I'm open to suggestions.

@thebaer thebaer added this to the 0.7.1 milestone Jan 8, 2019

@MasterGroosha

This comment has been minimized.

Copy link

MasterGroosha commented Jan 8, 2019

@thebaer Maybe you should first ask which backend to use - MySQL or SQLite and if the answer is SQLite, then stop config utility with message "Please run writefreely --init-db first and restart this config"

@thebaer

This comment has been minimized.

Copy link
Member

thebaer commented Jan 8, 2019

That user-creation step doesn't depend on the database type -- it only happens if you're setting up a single-user instance, like @geekgonecrazy mentioned. If it is single-user, you have to create that first user while setting things up (there's no way to do it via the web). So I think we should make that as easy as possible and automatically include the init-db step during single-user configuration.

We'll keep the init-db command available; I just think it'll be best to reduce the number of steps for people during install.

@thebaer thebaer closed this in 062ae0e Jan 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment