From bd19b91e059056b741c3418e3e9fbf0433f410be Mon Sep 17 00:00:00 2001 From: Mike Dalessio Date: Sat, 29 Nov 2025 14:09:55 -0500 Subject: [PATCH] Make sure the sqlite db is prepared in SAAS mode Previously, the mysql database was prepared twice and sqlite not at all. --- bin/setup | 7 +++++++ config/database.yml | 4 +--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/bin/setup b/bin/setup index 5a3eda882..b89de589d 100755 --- a/bin/setup +++ b/bin/setup @@ -65,6 +65,13 @@ setup_database() { local label="${adapter:+ ($adapter)}" local env_cmd="${adapter:+env DATABASE_ADAPTER=$adapter}" + # When setting up sqlite in SAAS mode, we need to disable SAAS so that + # database.yml will use database.sqlite.yml instead of the fizzy-saas config. + # We also unset BUNDLE_GEMFILE so the standard Gemfile is used (without fizzy-saas). + if [ -n "$SAAS" ] && [ "$adapter" = "sqlite" ]; then + env_cmd="env DATABASE_ADAPTER=$adapter SAAS=false BUNDLE_GEMFILE=" + fi + if [ "$reset" = "true" ]; then step "Resetting the database$label" $env_cmd rails db:reset else diff --git a/config/database.yml b/config/database.yml index 0229af3e3..d5ab7dbc0 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,11 +1,9 @@ <% - require_relative "../lib/fizzy" - config_path = if Fizzy.saas? gem_path = Gem::Specification.find_by_name("fizzy-saas").gem_dir File.join(gem_path, "config", "database.yml") else - File.join(__dir__, "database.#{Fizzy.db_adapter}.yml") + File.join("config", "database.#{Fizzy.db_adapter}.yml") end %> <%= ERB.new(File.read(config_path)).result %>