Run database create for sqlite

This commit is contained in:
Nabeel Shahzad 2017-12-14 22:32:52 -06:00
parent 1e866f8fa7
commit 80c69552f2
3 changed files with 12 additions and 10 deletions

View File

@ -117,7 +117,7 @@ class InstallerController extends AppBaseController
);
$log[] = 'Creating database';
$console_out = $this->dbService->setupDB();
$console_out = $this->dbService->setupDB($request->input('db_conn'));
return view('installer::steps/step2a-completed', [
'console_output' => $console_out

View File

@ -12,11 +12,11 @@ class DatabaseService {
* @throws \PDOException
* @return boolean
*/
public function checkDbConnection($type, $host, $port, $name, $user, $pass)
public function checkDbConnection($driver, $host, $port, $name, $user, $pass)
{
Log::info('Testing Connection: '.$type.'::'.$user.':'.$pass.'@'.$host.':'.$port.';'.$name);
Log::info('Testing Connection: '.$driver.'::'.$user.':'.$pass.'@'.$host.':'.$port.';'.$name);
if($type === 'mysql') {
if($driver === 'mysql') {
$dsn = "mysql:host=$host;port=$port;";
Log::info('Connection string: '. $dsn);
try {
@ -27,7 +27,7 @@ class DatabaseService {
}
// Needs testing
elseif ($type === 'postgres') {
elseif ($driver === 'postgres') {
$dsn = "pgsql:host=$host;port=$port;dbname=$name";
try {
$conn = new PDO($dsn, $user, $pass);
@ -42,12 +42,14 @@ class DatabaseService {
/**
* Setup the database by running the migration commands
*/
public function setupDB()
public function setupDB($db_driver='')
{
$output = '';
#\Artisan::call('database:create');
#$output .= \Artisan::output();
if($db_driver === 'sqlite') {
\Artisan::call('database:create');
$output .= \Artisan::output();
}
\Artisan::call('migrate');
$output .= trim(\Artisan::output());

View File

@ -11,12 +11,12 @@ class EnvironmentService
* Create the .env file
* @return boolean
*/
public function createEnvFile($type, $host, $port, $name, $user, $pass)
public function createEnvFile($driver, $host, $port, $name, $user, $pass)
{
$opts = [
'APP_ENV' => 'dev',
'APP_KEY' => $this->createAppKey(),
'DB_CONN' => $type,
'DB_CONN' => $driver,
'DB_HOST' => $host,
'DB_PORT' => $port,
'DB_NAME' => $name,