Skip to content
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
7 changes: 7 additions & 0 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions config/database.yml
Original file line number Diff line number Diff line change
@@ -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 %>