scribe/config/database.cr
Edward Loveall fcf3eb14d0
Initial app
2021-05-01 17:03:38 -04:00

20 lines
670 B
Crystal

database_name = "scribe_#{Lucky::Env.name}"
AppDatabase.configure do |settings|
if Lucky::Env.production?
settings.credentials = Avram::Credentials.parse(ENV["DATABASE_URL"])
else
settings.credentials = Avram::Credentials.parse?(ENV["DATABASE_URL"]?) || Avram::Credentials.new(
database: database_name,
hostname: ENV["DB_HOST"]? || "localhost",
port: ENV["DB_PORT"]?.try(&.to_i) || 5432,
username: ENV["DB_USERNAME"]? || "postgres",
password: ENV["DB_PASSWORD"]? || "postgres"
)
end
end
Avram.configure do |settings|
settings.database_to_migrate = AppDatabase
settings.lazy_load_enabled = Lucky::Env.production?
end