Use the external DB configuration as the local DB configuration by default

This allows admin to store all the tables in one unique DB
This commit is contained in:
Timothée Jaussoin 2021-05-10 17:07:35 +02:00
parent 8fcc6c1e46
commit ad69828d60
6 changed files with 41 additions and 30 deletions

View file

@ -28,8 +28,8 @@ PRIVACY_POLICY_URL= # A URL pointing to the Privacy Policy
LOG_CHANNEL=stack
# Local FlexiAPI database
DB_DATABASE=/var/www/flexiapi/db.sqlite
# Local FlexiAPI database, deprecated, the external database is used
# DB_DATABASE=/var/www/flexiapi/db.sqlite
# External FlexiSIP database
DB_EXTERNAL_DRIVER=mysql

View file

@ -17,11 +17,16 @@ Clone the repository, install the dependencies and generate a key.
composer install --no-dev
php artisan key:generate
Then configure the two databases connections in the `.env` file (from the `.env.example` one). And migrate the tables.
Then configure the database connection in the `.env` file (from the `.env.example` one). And migrate the tables.
php artisan migrate
The local one (that is by default using SQLite) is used to store authentications sessions. The remote one should be configured to connect directly to the Flexisip database.
FlexiAPI can store its local tables in a separate SQLite database. To enable it uncomment and complete the following configuration in the .env file
# DB_DRIVER=sqlite
# DB_DATABASE=/home/edhelas/Repositories/flexisip-account-manager/flexiapi/storage/db.sqlite
By default both local and remote data are stored in the Flexisip account database. You can configure it using the `DB_EXTERNAL_*` parameters in the `.env` file.
You can also run the test suit using `phpunit`.

46
flexiapi/composer.lock generated
View file

@ -1115,16 +1115,16 @@
},
{
"name": "league/commonmark",
"version": "1.6.0",
"version": "1.6.1",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/commonmark.git",
"reference": "19a9673b833cc37770439097b381d86cd125bfe8"
"reference": "2651c497f005de305c7ba3f232cbd87b8c00ee8c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/19a9673b833cc37770439097b381d86cd125bfe8",
"reference": "19a9673b833cc37770439097b381d86cd125bfe8",
"url": "https://api.github.com/repos/thephpleague/commonmark/zipball/2651c497f005de305c7ba3f232cbd87b8c00ee8c",
"reference": "2651c497f005de305c7ba3f232cbd87b8c00ee8c",
"shasum": ""
},
"require": {
@ -1212,7 +1212,7 @@
"type": "tidelift"
}
],
"time": "2021-05-01T19:00:49+00:00"
"time": "2021-05-08T16:08:00+00:00"
},
{
"name": "league/flysystem",
@ -1556,16 +1556,16 @@
},
{
"name": "nikic/php-parser",
"version": "v4.10.4",
"version": "v4.10.5",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
"reference": "c6d052fc58cb876152f89f532b95a8d7907e7f0e"
"reference": "4432ba399e47c66624bc73c8c0f811e5c109576f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/c6d052fc58cb876152f89f532b95a8d7907e7f0e",
"reference": "c6d052fc58cb876152f89f532b95a8d7907e7f0e",
"url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/4432ba399e47c66624bc73c8c0f811e5c109576f",
"reference": "4432ba399e47c66624bc73c8c0f811e5c109576f",
"shasum": ""
},
"require": {
@ -1606,9 +1606,9 @@
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
"source": "https://github.com/nikic/PHP-Parser/tree/v4.10.4"
"source": "https://github.com/nikic/PHP-Parser/tree/v4.10.5"
},
"time": "2020-12-20T10:01:03+00:00"
"time": "2021-05-03T19:11:20+00:00"
},
{
"name": "opis/closure",
@ -1998,16 +1998,16 @@
},
{
"name": "psr/log",
"version": "1.1.3",
"version": "1.1.4",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc"
"reference": "d49695b909c3b7628b6289db5479a1c204601f11"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/0f73288fd15629204f9d42b7055f72dacbe811fc",
"reference": "0f73288fd15629204f9d42b7055f72dacbe811fc",
"url": "https://api.github.com/repos/php-fig/log/zipball/d49695b909c3b7628b6289db5479a1c204601f11",
"reference": "d49695b909c3b7628b6289db5479a1c204601f11",
"shasum": ""
},
"require": {
@ -2031,7 +2031,7 @@
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for logging libraries",
@ -2042,9 +2042,9 @@
"psr-3"
],
"support": {
"source": "https://github.com/php-fig/log/tree/1.1.3"
"source": "https://github.com/php-fig/log/tree/1.1.4"
},
"time": "2020-03-23T09:12:05+00:00"
"time": "2021-05-03T11:20:27+00:00"
},
{
"name": "psr/simple-cache",
@ -5033,16 +5033,16 @@
},
{
"name": "facade/ignition",
"version": "2.8.4",
"version": "2.9.0",
"source": {
"type": "git",
"url": "https://github.com/facade/ignition.git",
"reference": "87fb348dab0ae1a7c206c3e902a5a44ba541742f"
"reference": "e7db3b601ce742568b92648818ef903904d20164"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/facade/ignition/zipball/87fb348dab0ae1a7c206c3e902a5a44ba541742f",
"reference": "87fb348dab0ae1a7c206c3e902a5a44ba541742f",
"url": "https://api.github.com/repos/facade/ignition/zipball/e7db3b601ce742568b92648818ef903904d20164",
"reference": "e7db3b601ce742568b92648818ef903904d20164",
"shasum": ""
},
"require": {
@ -5106,7 +5106,7 @@
"issues": "https://github.com/facade/ignition/issues",
"source": "https://github.com/facade/ignition"
},
"time": "2021-04-29T13:55:26+00:00"
"time": "2021-05-05T06:45:12+00:00"
},
{
"name": "facade/ignition-contracts",

Binary file not shown.

View file

@ -53,9 +53,15 @@ return [
'connections' => [
'local' => [
'driver' => env('DB_DRIVER', 'sqlite'),
'driver' => env('DB_DRIVER', env('DB_EXTERNAL_DRIVER', 'mysql')),
'url' => env('DATABASE_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')),
'host' => env('DB_EXTERNAL_HOST', '127.0.0.1'),
'port' => env('DB_EXTERNAL_PORT', '3306'),
'database' => env('DB_DATABASE', env('DB_EXTERNAL_DATABASE', database_path('database.sqlite'))),
'username' => env('DB_EXTERNAL_USERNAME', 'forge'),
'password' => env('DB_EXTERNAL_PASSWORD', ''),
'charset' => env('DB_EXTERNAL_DRIVER', 'mysql') == 'mysql' ? 'utf8mb4' : null,
'collation' => env('DB_EXTERNAL_DRIVER', 'mysql') == 'mysql' ? 'utf8mb4_unicode_ci' : null,
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
],

View file

@ -8,7 +8,7 @@
#%define _datadir %{_datarootdir}
#%define _docdir %{_datadir}/doc
%define build_number 70
%define build_number 71
%define var_dir /var/opt/belledonne-communications
%define opt_dir /opt/belledonne-communications/share/flexisip-account-manager