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 usage #122

Closed
Arteneko opened this issue Jul 30, 2021 · 13 comments · Fixed by #172
Closed

SQLite usage #122

Arteneko opened this issue Jul 30, 2021 · 13 comments · Fixed by #172
Assignees
Labels
enhancement New feature or request

Comments

@Arteneko
Copy link
Contributor

For small (and single-user) instances, it would alleviate the maintenance burden to allow running an instance using SQLite as RDBMS.

Would you consider it something possible for this project?

@tsmethurst tsmethurst added the enhancement New feature or request label Jul 30, 2021
@tsmethurst
Copy link
Contributor

In theory it's definitely possible, since we abstracted the database connection into an interface that should work with dependency injection (so you can connect it to any kind of DB that can fulfill the interface).

In practice, we still need to tidy up the existing database functionality a bit, and work on basic features before we can put this on the roadmap.

So........... maybe! But not immediately.

@Arteneko
Copy link
Contributor Author

I guess i would try to implement myself then, since I've been meaning to use it on my own host.

@decentral1se
Copy link
Contributor

Just to chime in, I think this would be a wonderful addition to GtS 🚀

@5HT2
Copy link

5HT2 commented Aug 1, 2021

To add to this, once this is possible it would be nice to add something to the docs that explains how to connect it to an existing masto / flavor database.

@charlag
Copy link

charlag commented Aug 1, 2021

I considered the same for my own project but decided against it:

  1. SQLite is single-threaded so it will limit how fast you can do certain things (but it might be fine still)
  2. Need to re-do all JSON operations because JSON subsystems are pretty different between pg and sqlite (but idk how it is here)

so it's something to keep in mind!

@tsmethurst
Copy link
Contributor

To add to this, once this is possible it would be nice to add something to the docs that explains how to connect it to an existing masto / flavor database.

@L1ving I made an issue for this here :) #128

@aschrijver
Copy link

Just some FYI's. Sqlite is getting a lot of attention on HN these days, and will probably suffice in production for small-scale instances. Here's some One process programming notes (with Go and SQLite). In this HN comment in a larger thread about Litestream (written in Go) some good tips on production-use. And if you wanna go wild, then use a cluster with rqlite (also written in Go).

@decentral1se
Copy link
Contributor

There is a pure go implementation now!? sqlite 🤯

@tsmethurst
Copy link
Contributor

There is a pure go implementation now!? sqlite exploding_head

this would be the implementation i suggest we go for, since i'd rather avoid gcc dependencies

@tsmethurst
Copy link
Contributor

I mentioned this issue in the above PR, because the database interface tidying up and reshuffling will affect how this is implemented (hopefully making it easier overall).

@tsmethurst
Copy link
Contributor

So, right now we use Go-PG for postgres connections and ORM. Looks like go-pg is now in maintenance mode, and the devs recommend migrating to Bun.

And bun (guess what!) also works with SQLite, and is apparently a bit faster than go-pg.

So the quickest step to getting sqlite working with gotosocial might just be to migrate from go-pg => bun

https://bun.uptrace.dev/guide/pg-migration.html#new-features

This was referenced Aug 23, 2021
@tsmethurst
Copy link
Contributor

Now that the migration to bun is complete, the starting point for adding an SQLite implementation is here: https://github.com/superseriousbusiness/gotosocial/blob/main/internal/db/bundb/bundb.go#L89-L91

Since sqlite doesn't use the same sort of connection options as postgres, this will also probably necessitate some changes to the database configuration in the following locations (at least)

https://github.com/superseriousbusiness/gotosocial/blob/main/internal/config/db.go
https://github.com/superseriousbusiness/gotosocial/blob/main/internal/config/config.go
https://github.com/superseriousbusiness/gotosocial/blob/main/cmd/gotosocial/databaseflags.go

@NyaaaWhatsUpDoc
Copy link
Member

Currently being tackled in #154

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants