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

Use postgres as the default setup db #1058

Merged
merged 1 commit into from
Aug 25, 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: 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