Skip to content

Commit

Permalink
Use postgres as the default setup db to make things easier for new us…
Browse files Browse the repository at this point in the history
…ers. Fixes #1056 (#1058)
  • Loading branch information
jwoertink authored Aug 25, 2024
1 parent a10cb05 commit f48db0d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/avram.cr
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ module Avram
setting time_formats : Array(String) = [] of String
setting i18n_backend : Avram::I18nBackend = Avram::I18n.new, example: "Avram::I18n.new"
setting query_cache_enabled : Bool = false
# This setting is used to connect to postgres before you've setup your app's DB.
# If `postgres` isn't available, you can update to `template1` or some other default DB
setting setup_database_name : String = "postgres"
end

Log = ::Log.for(Avram)
Expand Down
4 changes: 2 additions & 2 deletions src/avram/migrator/runner.cr
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Avram::Migrator::Runner
end

def self.drop_db(quiet? : Bool = false)
DB.connect("#{credentials.connection_string}/#{db_user}") do |db|
DB.connect("#{credentials.connection_string}/#{Avram.settings.setup_database_name}") do |db|
db.exec "DROP DATABASE IF EXISTS #{db_name}"
end
unless quiet?
Expand All @@ -78,7 +78,7 @@ class Avram::Migrator::Runner
end

def self.create_db(quiet? : Bool = false)
DB.connect("#{credentials.connection_string}/#{db_user}") do |db|
DB.connect("#{credentials.connection_string}/#{Avram.settings.setup_database_name}") do |db|
db.exec "CREATE DATABASE #{db_name}"
end
unless quiet?
Expand Down

0 comments on commit f48db0d

Please sign in to comment.