Fixed error with cli command

This commit is contained in:
Sergio Brighenti 2020-04-13 17:46:10 +02:00
parent 5a7c74c5d9
commit 2303cb263f
5 changed files with 28 additions and 5 deletions

View file

@ -3,6 +3,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [3.1.4] - 2020-04-13
### Changed
- Now the migrate command resync the system quota for each user.
### Fixed
- Fixed error with the migrate command.
## [3.1.3] - 2020-04-13 ## [3.1.3] - 2020-04-13
### Changed ### Changed
- Added changelog page. - Added changelog page.

View file

@ -5,23 +5,32 @@ if (php_sapi_name() !== 'cli') {
die(); die();
} }
use App\Database\DB;
use App\Database\Migrator; use App\Database\Migrator;
use DI\ContainerBuilder;
require __DIR__.'/../vendor/autoload.php'; require __DIR__.'/../vendor/autoload.php';
define('BASE_DIR', realpath(__DIR__.'/../').DIRECTORY_SEPARATOR);
$config = include __DIR__.'/../config.php'; $config = include __DIR__.'/../config.php';
if (!$config) { if (!$config) {
die('config.php not found. Please create a new one.'); die('config.php not found. Please create a new one.');
} }
chdir(__DIR__.'/../'); chdir(BASE_DIR);
$db = new DB(dsnFromConfig($config), $config['db']['username'], $config['db']['password']); $builder = new ContainerBuilder();
$builder->addDefinitions(BASE_DIR.'bootstrap/container.php');
$container = $builder->build();
$container->set('config', $config);
$db = $container->get('database');
$migrator = new Migrator($db, 'resources/schemas'); $migrator = new Migrator($db, 'resources/schemas');
$migrator->migrate(); $migrator->migrate();
$migrator->reSyncQuotas($container->get('storage'));
if (isset($argv[1]) && $argv[1] === '--install') { if (isset($argv[1]) && $argv[1] === '--install') {
$db->query("INSERT INTO `users` (`email`, `username`, `password`, `is_admin`, `user_code`) VALUES ('admin@example.com', 'admin', ?, 1, ?)", [password_hash('admin', PASSWORD_DEFAULT), humanRandomString(5)]); $db->query("INSERT INTO `users` (`email`, `username`, `password`, `is_admin`, `user_code`) VALUES ('admin@example.com', 'admin', ?, 1, ?)", [password_hash('admin', PASSWORD_DEFAULT), humanRandomString(5)]);

View file

@ -1,7 +1,7 @@
{ {
"name": "sergix44/xbackbone", "name": "sergix44/xbackbone",
"license": "AGPL-3.0", "license": "AGPL-3.0",
"version": "3.1.3", "version": "3.1.4",
"description": "A lightweight ShareX PHP backend", "description": "A lightweight ShareX PHP backend",
"type": "project", "type": "project",
"require": { "require": {

2
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "3a1bab97259e3ebc3e6ffcdeeae0f8c0", "content-hash": "ff10819e8baf13d2451593e29f1d76a2",
"packages": [ "packages": [
{ {
"name": "aws/aws-sdk-php", "name": "aws/aws-sdk-php",

View file

@ -8,6 +8,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
## [3.1.4] - 2020-04-13
### Changed
- Now the migrate command resync the system quota for each user.
### Fixed
- Fixed error with the migrate command.
## [3.1.3] - 2020-04-13 ## [3.1.3] - 2020-04-13
### Changed ### Changed
- Added changelog page. - Added changelog page.