Skip to content
This repository has been archived by the owner on May 19, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1212 from joaopaulofilho/master
Browse files Browse the repository at this point in the history
correctly detects if there is a database and if there [are] any tables [created]
  • Loading branch information
TheBrenny authored Jul 8, 2017
2 parents e32c5e5 + 74f80ae commit 6f6e696
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions install/libraries/installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,22 @@ public static function run()

// check we have not already installed
if (!static::$connection->instance()->query('SHOW DATABASES LIKE ' . static::$connection->instance()->quote($settings['database']['name']) . ';')->fetchColumn()) {

// create the database and use the database
static::$connection->instance()->query('CREATE DATABASE ' . substr(static::$connection->instance()->quote($settings['database']['name']),1,-1) . ';');
static::$connection->instance()->query('USE ' . substr(static::$connection->instance()->quote($settings['database']['name']),1,-1) . ';');

// install tables
static::schema($settings);

// insert metadata
static::metadata($settings);

// create user account
static::account($settings);
// create the database
static::$connection->instance()->query('CREATE DATABASE ' . substr(static::$connection->instance()->quote($settings['database']['name']),1,-1) . ';');
}

// use the database
static::$connection->instance()->query('USE ' . substr(static::$connection->instance()->quote($settings['database']['name']),1,-1) . ';');

if (!static::$connection->instance()->query('SHOW TABLES;')->fetchColumn()) {
// install tables
static::schema($settings);

// insert metadata
static::metadata($settings);

// create user account
static::account($settings);
}

// write database config
Expand Down

0 comments on commit 6f6e696

Please sign in to comment.