Skip to content

Commit bd19b91

Browse files
committed
Make sure the sqlite db is prepared in SAAS mode
Previously, the mysql database was prepared twice and sqlite not at all.
1 parent cb3ca8f commit bd19b91

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

bin/setup

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ setup_database() {
6565
local label="${adapter:+ ($adapter)}"
6666
local env_cmd="${adapter:+env DATABASE_ADAPTER=$adapter}"
6767

68+
# When setting up sqlite in SAAS mode, we need to disable SAAS so that
69+
# database.yml will use database.sqlite.yml instead of the fizzy-saas config.
70+
# We also unset BUNDLE_GEMFILE so the standard Gemfile is used (without fizzy-saas).
71+
if [ -n "$SAAS" ] && [ "$adapter" = "sqlite" ]; then
72+
env_cmd="env DATABASE_ADAPTER=$adapter SAAS=false BUNDLE_GEMFILE="
73+
fi
74+
6875
if [ "$reset" = "true" ]; then
6976
step "Resetting the database$label" $env_cmd rails db:reset
7077
else

config/database.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
<%
2-
require_relative "../lib/fizzy"
3-
42
config_path = if Fizzy.saas?
53
gem_path = Gem::Specification.find_by_name("fizzy-saas").gem_dir
64
File.join(gem_path, "config", "database.yml")
75
else
8-
File.join(__dir__, "database.#{Fizzy.db_adapter}.yml")
6+
File.join("config", "database.#{Fizzy.db_adapter}.yml")
97
end
108
%>
119
<%= ERB.new(File.read(config_path)).result %>

0 commit comments

Comments
 (0)