Last active
June 8, 2018 09:24
-
-
Save joscdk/ab3183a558b18a128dc7258a0f3cdaff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var databases = DatabasesConfig() | |
let databaseConfig: PostgreSQLDatabaseConfig | |
if let url = Environment.get("DB_POSTGRESQL") { | |
databaseConfig = try PostgreSQLDatabaseConfig(url: url) | |
} else { | |
// Local configuration | |
let hostname = "localhost" | |
let username = "vapor" | |
let password = "password" | |
let database = "vapor" | |
databaseConfig = PostgreSQLDatabaseConfig( | |
hostname: hostname, | |
username: username, | |
database: database, | |
password: password | |
) | |
} | |
let database = PostgreSQLDatabase(config: databaseConfig) | |
databases.add(database: database, as: .psql) | |
services.register(databases) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment