Feature: SQLite for self hosting #750
Replies: 8 comments 10 replies
-
yes sqlite support would be very welcome |
Beta Was this translation helpful? Give feedback.
-
+1 Looks like the first big change would be the schema - currently the entire schema is using |
Beta Was this translation helpful? Give feedback.
-
@henrikbjorn @brtwrst @danwetherald what are the primary reasons you'd prefer Sqlite over Postgres? I'd like to understand specific use cases in greater detail. |
Beta Was this translation helpful? Give feedback.
-
@zachgoll - Self hosting is much simpler using SQLite - If deployed to fly.io (for example) - this eliminated an entire second app for the DB which needs 3 machines running 24/7. When self hosting for usage of 1-2 people with occasional usage, it would be nice to scale machines / servers to zero - this is a bit tougher with Postgres. Also, you are already using good job, should also think about moving to solid queue powered by SQLite. (as this is the default in Rails 8) |
Beta Was this translation helpful? Give feedback.
-
I host things locally on tiny/small servers, think raspberry pi. Basically everything is single user. |
Beta Was this translation helpful? Give feedback.
-
If we look at this project only through the lens of self-hosting then SQLite makes sense. But, not sure what are the plans with the "hosted by Maybe" option? |
Beta Was this translation helpful? Give feedback.
-
I was tinkering with this today. As @danwetherald pointed out, the first issue I encountered was using UUIDs for keys, but I saw that blog post that showed some steps for adding the necessary gems and extensions to support ULIDs in SQLite. The other issue I encountered was that SQLite does not support a JSONB field type, but I think it supports JSON? |
Beta Was this translation helpful? Give feedback.
-
Thought about this some more. I think one big issue is that the migrations currently use UUIDs for the primary keys. AFAIK SQLite does not support UUID data types. So out of the box, none of the migrations can run. Now one could write a Rake task to parse all the migrations and swap the primary and foreign key column types to integer (or even ULIDs) which should allow the migrations to run at a point in time. However, an issue of future migrations will remain. That is, whenever the team creates/modifies tables with UUIDs, apps using SQLite won't be able to run those migrations out of the box unless the UUID columns are replaced. Maybe there is a mechanism where one could hook into the Rails |
Beta Was this translation helpful? Give feedback.
-
Feature Overview
Would be great if there was an option to use SQLite for hosting (especially selfhost). It does not seem that sqlite package nor gem is part of the Gemfile or Dockerfile.
Requirements
If there is a missing / incorrect requirement, please leave a comment before starting work on this.
Implementation Suggestions
Use the gem from Fractaledmind https://fractaledmind.github.io/2024/04/15/sqlite-on-rails-the-how-and-why-of-optimal-performance/ and maybe tune something a bit based on his post
Beta Was this translation helpful? Give feedback.
All reactions