irskep / cheapo_website

An experiment in production SQLite on render.com and fly.io
43 stars 1 forks source link

Suggestions to Explore/Document: DB Administration/Querying, Encryption at Rest #1

Open I-Dont-Remember opened 1 year ago

I-Dont-Remember commented 1 year ago

Love the idea behind this repo (and your comment on hn)! Have ran into similar questions when I started trying to actually use SQLite for a production grade app like so many articles suggest. Had a couple more questions I've run into that may be useful for those exploring SQLite in the future (not that you're required to find answers for them, but figured it was worth at least attaching to the repo):

Security/Encryption at Rest

SQLite has different security considerations as a plain file than something like PostgreSQL does as a server. If someone grabs the file, they have your whole database and can query it.

DB Administration/Querying

If you're running an app, at some point you'll likely need to be able to easily edit a field for a user, or check their state. Since it's not a running server, you can't just attach to the DB from SQLWorkbench or the like.

Backups

Might be worth mentioning Litestream since it's commonly suggested, even if it you don't want it implemented on the project.

Other topics

I'm sure there are large topics that haven't been covered but would be worth discussing.

irskep commented 1 year ago

Thanks for the feedback!

SQLite has different security considerations as a plain file than something like PostgreSQL does as a server. If someone grabs the file, they have your whole database and can query it.

I'd consider this an unavoidable downside of using SQLite. Best you can do is store the DB on an encrypted disk, which you should be able to configure with the cloud provider.

If you're running an app, at some point you'll likely need to be able to easily edit a field for a user, or check their state. Since it's not a running server, you can't just attach to the DB from SQLWorkbench or the like.

You should either write an admin site if you need to do this often, or have command line scripts you can run on your web machines. It's safe to write to the same DB from multiple processes as long as WAL mode is enabled (or so I've been told).

That's why the migration instructions are now just "SSH in and run make maintenance-db-upgrade." :-)

Might be worth mentioning Litestream since it's commonly suggested, even if it you don't want it implemented on the project.

Yeah, and I'm also waiting for LiteFS to be released. I'll consider mentioning these in the future.