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

Support SQLite databases in production #2364

Merged
merged 3 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@ gem "ffi-libarchive", "~> 1.1"
# Reduces boot times through caching; required in config/boot.rb
gem "bootsnap", ">= 1.4.4", require: false

# Database adapters
gem "sqlite3", "~> 1.7"
group :production do
gem "pg", "~> 1.5"
end

group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem "byebug", platforms: [:mri, :mingw, :x64_mingw]
gem "sqlite3", "~> 1.7"
gem "rspec-rails"
gem "standard", "~> 1.39.1"
gem "factory_bot"
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/concerns/model_filters.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def process_filters
if @filters[:missingtag].presence || (@filters[:missingtag] && @filters[:library])
tag_regex_build = []
regexes = ((@filters[:missingtag] != "") ? [@filters[:missingtag]] : @models[0].library.tag_regex)
# technically this is sqlite vs postgres
regact = Rails.env.development? ? "REGEXP" : "~"
# work out regexp match syntax
regact = ApplicationRecord.connection.is_a?(ActiveRecord::ConnectionAdapters::SQLite3Adapter) ? "REGEXP" : "~"
regexes.each do |reg|
qreg = ActiveRecord::Base.connection.quote(reg)
tag_regex_build.push "(select count(*) from tags join taggings on tags.id=taggings.tag_id where tags.name #{regact} #{qreg} and taggings.taggable_id=models.id and taggings.taggable_type='Model')<1"
Expand Down
14 changes: 9 additions & 5 deletions docker-compose.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,16 @@ services:
PGID: 1000 # The ID of the group the app will run as
SECRET_KEY_BASE: a_nice_long_random_string
REDIS_URL: redis://redis:6379/1

# Database connection string
DATABASE_URL: postgresql://manyfold:password@db/manyfold?pool=5
# or
# DATABASE_HOST: db
# DATABASE_USER: manyfold
# DATABASE_PASSWORD: password
# DATABASE_NAME: manyfold

# You can also use SQLite if you don't want to run a separate database server.
# Make sure the specified path is on a persistent volume!
# DATABASE_URL: sqlite3:/config/manyfold.sqlite3?pool=5

# Alternatively, you can set database connection parameters (host, username, etc)
# in separate variables; see https://manyfold.app/sysadmin/configuration.html.

# For details of other optional environment variables, including features such
# as multiuser mode, visit https://manyfold.app/sysadmin/configuration.html
Expand Down
Loading