Skip to content

Commit

Permalink
Fixed error with migrate command (closes #115)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergix44 committed Dec 4, 2019
1 parent 3b8eba3 commit 3b7e2fa
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 80 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v.3.0.2
+ Fixed error with migrate command.
+ Updated translations.

## v.3.0.1
+ Fixed error with older mysql versions.
+ Fixed config is compiled with the di container.
Expand Down
7 changes: 4 additions & 3 deletions app/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,13 +436,14 @@ function glob_recursive($pattern, $flags = 0)
/**
* Return the database DSN from config.
*
* @param array $config
* @param array $config
*
* @param string $baseDir
* @return string
*/
function dsnFromConfig(array $config): string
function dsnFromConfig(array $config, $baseDir = BASE_DIR): string
{
$dsn = $config['db']['connection'] === 'sqlite' ? BASE_DIR.$config['db']['dsn'] : $config['db']['dsn'];
$dsn = $config['db']['connection'] === 'sqlite' ? $baseDir.$config['db']['dsn'] : $config['db']['dsn'];

return $config['db']['connection'].':'.$dsn;
}
Expand Down
2 changes: 1 addition & 1 deletion bin/migrate
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ if ($config['db']['connection'] === 'sqlite' && !file_exists(__DIR__.'/../'.$con
$firstMigrate = true;
}

$db = new DB(dsnFromConfig($config), $config['db']['username'], $config['db']['password']);
$db = new DB(dsnFromConfig($config, getcwd().DIRECTORY_SEPARATOR), $config['db']['username'], $config['db']['password']);

$migrator = new Migrator($db, 'resources/schemas', $firstMigrate);
$migrator->migrate();
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sergix44/xbackbone",
"version": "3.0.1",
"version": "3.0.2",
"description": "A lightweight ShareX PHP backend",
"type": "project",
"require": {
Expand Down
Loading

0 comments on commit 3b7e2fa

Please sign in to comment.