Skip to content
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

SQLite support #45

Merged
merged 19 commits into from
Dec 10, 2018
Merged

SQLite support #45

merged 19 commits into from
Dec 10, 2018

Conversation

thebaer
Copy link
Member

@thebaer thebaer commented Dec 8, 2018

This adds support for data storage in SQLite, instead of MySQL. [Phabricator discussion here]

  • New optional [database] type config value: sqlite3
  • New config field: [database] filename - determines the name of the SQLite database file (default: writefreely.db)
  • New step in the configuration process that prompts for the database driver and SQLite filename (if that's the chosen option)
  • Helper methods in database.go for handling differences between MySQL and SQLite
  • New sqlite.sql file with SQLite-specific queries, bundled with all distributions

These changes also lay the groundwork for future support of other datastores, like PostgreSQL.

Everything worked well in my testing, but I'd like to get more people trying it out and seeing if anything breaks. Also, special thanks to @BenOvermyer for all the up-front work on this!

Ben Overmyer and others added 16 commits November 26, 2018 14:11
This keeps queries similar to schema.sql, and ensures log statements are
correct when running --init-db
A quick test with ApacheBench revealed that SQLite really can't handle
multiple concurrent requests with the default settings, due to a locked
database. This fixes that by following the suggestions here:
https://github.com/mattn/go-sqlite3#faq

Testing with ab -n 100 -c 5 http://localhost:8080/blog/post shows that
this fixes the issue. But we could improve performance by reducing
writes, like what's mentioned in T545.

Part of T529
The formatted string was invalid before, causing date parsing to fail.
This fixes that.

Ref T529
We store times in UTC in all other places, but the post.Created logic
when creating a post meant that dates were being stored in a user's
local timezone. This fixes that.

Ref T529
This extracts the LEFT/SUBSTR logic into its own datastore.clip() method
that also works correctly with SQLite.

Ref T529
@thebaer thebaer added this to the 0.6 milestone Dec 8, 2018
The field is currently unused in the app, and it was causing problems in
SQLite.

Ref T529
@thebaer
Copy link
Member Author

thebaer commented Dec 10, 2018

Running consistently over the weekend and haven't found any other issues. Still considering this "beta" functionality until it's more widely tested, but I think it's good enough to merge now.

@thebaer thebaer merged commit 2422601 into master Dec 10, 2018
@thebaer thebaer deleted the sqlite-support branch January 5, 2019 01:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

2 participants