2016-10-27 23:53:11 +02:00
|
|
|
<?php
|
|
|
|
|
2017-01-30 16:33:56 +01:00
|
|
|
// Bootstrap environment variables
|
2016-10-27 23:53:11 +02:00
|
|
|
|
2017-10-16 05:43:12 +02:00
|
|
|
use SilverStripe\Core\Environment;
|
2016-10-27 23:53:11 +02:00
|
|
|
|
2017-07-03 02:21:27 +02:00
|
|
|
/** @skipUpgrade */
|
2017-10-16 05:43:12 +02:00
|
|
|
if (!Environment::getEnv('SS_DATABASE_CLASS') && !Environment::getEnv('SS_DATABASE_USERNAME')) {
|
2016-12-16 05:34:21 +01:00
|
|
|
// The default settings let us define the database config via environment vars
|
|
|
|
// Database connection, including PDO and legacy ORM support
|
2017-10-16 05:43:12 +02:00
|
|
|
switch (Environment::getEnv('DB')) {
|
2016-12-16 05:34:21 +01:00
|
|
|
case "PGSQL";
|
2017-10-16 05:43:12 +02:00
|
|
|
$pgDatabaseClass = Environment::getEnv('PDO') ? 'PostgrePDODatabase' : 'PostgreSQLDatabase';
|
|
|
|
Environment::setEnv('SS_DATABASE_CLASS', $pgDatabaseClass);
|
|
|
|
Environment::setEnv('SS_DATABASE_USERNAME', 'postgres');
|
|
|
|
Environment::setEnv('SS_DATABASE_PASSWORD', '');
|
2017-01-30 16:33:56 +01:00
|
|
|
break;
|
2016-10-27 23:53:11 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
case "SQLITE":
|
2017-10-16 05:43:12 +02:00
|
|
|
$sqliteDatabaseClass = Environment::getEnv('PDO') ? 'SQLite3PDODatabase' : 'SQLite3Database';
|
|
|
|
Environment::setEnv('SS_DATABASE_CLASS', $sqliteDatabaseClass);
|
|
|
|
Environment::setEnv('SS_DATABASE_USERNAME', 'root');
|
|
|
|
Environment::setEnv('SS_DATABASE_PASSWORD', '');
|
|
|
|
Environment::setEnv('SS_SQLITE_DATABASE_PATH', ':memory:');
|
2016-12-16 05:34:21 +01:00
|
|
|
break;
|
2016-10-27 23:53:11 +02:00
|
|
|
|
2016-12-16 05:34:21 +01:00
|
|
|
default:
|
2017-10-16 05:43:12 +02:00
|
|
|
$mysqlDatabaseClass = Environment::getEnv('PDO') ? 'MySQLPDODatabase' : 'MySQLDatabase';
|
|
|
|
Environment::setEnv('SS_DATABASE_CLASS', $mysqlDatabaseClass);
|
|
|
|
Environment::setEnv('SS_DATABASE_USERNAME', 'root');
|
|
|
|
Environment::setEnv('SS_DATABASE_PASSWORD', '');
|
2016-12-16 05:34:21 +01:00
|
|
|
}
|
2016-10-27 23:53:11 +02:00
|
|
|
|
2017-10-16 05:43:12 +02:00
|
|
|
Environment::setEnv('SS_DATABASE_CHOOSE_NAME', 'true');
|
|
|
|
Environment::setEnv('SS_DATABASE_SERVER', '127.0.0.1');
|
2016-10-27 23:53:11 +02:00
|
|
|
}
|