active_storage_db icon indicating copy to clipboard operation
active_storage_db copied to clipboard

What would it take to use under SQLite3?

Open francois opened this issue 1 year ago • 3 comments

I'd be interested in running this gem with SQLite3 instead of PG. Backing up the database in a single file would be so very interesting!

I tried setting up Appraisal (and removing MySQL and MSSQL as I don't have that installed), but when I ran, I got the following:

$ bundle exec appraisal rails-7_1-sqlite3 rspec
>> BUNDLE_GEMFILE=/Users/francois/Projects/scoutges/active_storage_db/gemfiles/rails_7_1_sqlite3.gemfile bundle exec rspec

An error occurred while loading rails_helper.
Failure/Error: require File.expand_path("dummy#{app_ver}/config/environment.rb", __dir__)

LoadError:
  cannot load such file -- /Users/francois/Projects/scoutges/active_storage_db/spec/dummy/config/environment.rb
# ./spec/rails_helper.rb:37:in `<top (required)>'
No examples found.

Finished in 0.00003 seconds (files took 0.21598 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples

I suspect the environment isn't correctly setup.

I would be interested in making this gem work. What would it take?

francois avatar Mar 25 '24 03:03 francois

Hey @francois

The error that you receive is probably related to the environment variables needed to setup the test config. For example for Postgres and Rails 7.x I use:

DB_TEST=postgres RAILS=7.0 be appraisal rails-7_1-postgres rspec

Honestly I should evaluate carefully what it would be required to make the gem work with SQLite, but it seems a very specific use case to me because ActiveStorage can store the attachments on the filesystem on its own...

blocknotes avatar Apr 18 '24 14:04 blocknotes

@blocknotes, I'm interested in storing data to a SQLite because then I will have a single file backup, and all data will be consistent with each other. Thanks for the pointer. I'll try that.

francois avatar Apr 19 '24 13:04 francois

Hey @francois

I prepared an experimental PR to add SQLite support: https://github.com/blocknotes/active_storage_db/pull/51

The branch is: feat/sqlite-support

If you have a chance to make some tests, please share the results.

blocknotes avatar Sep 08 '24 08:09 blocknotes