mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-30 18:41:08 +00:00
Some command fixes.
This commit is contained in:
@@ -54,8 +54,8 @@ if [[ ! -z "$DB_PORT" ]]; then
|
|||||||
fi
|
fi
|
||||||
#env $(grep -v "^\#" .env | xargs)
|
#env $(grep -v "^\#" .env | xargs)
|
||||||
php artisan cache:clear
|
php artisan cache:clear
|
||||||
php artisan migrate --seed
|
|
||||||
php artisan firefly-iii:create-database
|
php artisan firefly-iii:create-database
|
||||||
|
php artisan migrate --seed
|
||||||
php artisan firefly-iii:decrypt-all
|
php artisan firefly-iii:decrypt-all
|
||||||
|
|
||||||
# there are 13 upgrade commands
|
# there are 13 upgrade commands
|
||||||
|
@@ -50,16 +50,20 @@ class CreateDatabase extends Command
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
// with PDO, try to list DB's (
|
// with PDO, try to list DB's (
|
||||||
$stmt = $pdo->prepare('SHOW DATABASES WHERE `Database` = ?');
|
$stmt = $pdo->query('SHOW DATABASES;');
|
||||||
$stmt->execute([env('DB_DATABASE')]);
|
$exists = false;
|
||||||
$result = $stmt->fetch();
|
// slightly more complex but less error prone.
|
||||||
if (false === $result) {
|
foreach ($stmt as $row) {
|
||||||
|
$name = $row['Database'] ?? false;
|
||||||
|
if ($name === env('DB_DATABASE')) {
|
||||||
|
$exists = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (false === $exists) {
|
||||||
$this->error(sprintf('Database "%s" does not exist.', env('DB_DATABASE')));
|
$this->error(sprintf('Database "%s" does not exist.', env('DB_DATABASE')));
|
||||||
|
|
||||||
// try to create it.
|
// try to create it.
|
||||||
$stmt = $pdo->query(sprintf('CREATE DATABASE `%s` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;', env('DB_DATABASE')));
|
$pdo->exec(sprintf('CREATE DATABASE `%s` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;', env('DB_DATABASE')));
|
||||||
$stmt->execute();
|
|
||||||
$stmt->fetch();
|
|
||||||
$this->info(sprintf('Created database "%s"', env('DB_DATABASE')));
|
$this->info(sprintf('Created database "%s"', env('DB_DATABASE')));
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user