Laravel multiple database can not connect
Opened this issue · 0 comments
gbekura commented
We are encoutering troubles with connecting platform sh Databases to laravel.
for example we have services yml:
# The name of the service container. Must be unique within a project.
db5:
type: mariadb:11.2
disk: 2048
configuration:
schemas:
- archfix_ibc
- archfix_static
endpoints:
mysql:
default_schema: archfix_ibc
privileges:
archfix_ibc: admin
mysql2:
default_schema: archfix_static
privileges:
archfix_static: admin
And app relationships:
relationships:
mysql:
service: db5
endpoint: mysql
mysql2:
service: db5
endpoint: mysql2
database.php db configs:
'mysql2' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST_2', '127.0.0.1'),
'port' => env('DB_PORT_2', '30001'),
'database' => env('DB_DATABASE_2', 'archfix_static'),
'username' => env('DB_USERNAME_2', 'user'),
'password' => env('DB_PASSWORD_2', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
'mysql' => [
'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
'options' => extension_loaded('pdo_mysql') ? array_filter([
PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'),
]) : [],
],
And it won't connect to the database. User manual lacks information about non standard cases.
I assume that it only works if relationship is called database and laravel app has only one database.