Often we will want to change which database the API is pointing to. This could be for development or emergency management purposes. With the Schema module using [DBIx::Class::Schema::Config]() for configuration (see https://github.com/cpan-testers/cpantesters-schema/issues/3), we have an easy way to refer to known databases with a simple string. But, we should also provide a way to override the global database configs with our own local ones for flexibility and in case of emergency.
Using the Mojolicious Config plugin, create a section in the config called schema. This section should be a hash reference and contain the keys:
database, which is either a name of a database in the DBIx::Class::Schema::Config configuration file or a full DBI data source name (DSN)
user, which is the user to connect with (or override the DBIC::Schema::Config user with)
password, which is the password to connect with (or override the DBIC::Schema::Config password with)
args, which is a hash reference of additional arguments to DBI (things like PrintError => 0 and the like), and which will likely be rarely used except to get some better debug logging
Since we install the API application via CPAN, we will need to either use the MOJO_CONFIG environment variable to point to the config file, or set the MOJO_HOME to control where Mojolicious::Plugin::Config looks for configuration files. We will also likely need to set the moniker of the CPAN::Testers::API application to something friendly like cpantesters-api so that our configuration file name is cpantesters-api.conf and/or cpantesters-api.$MOJO_MODE.conf.
The configuration file was added as part of e683dce68626b62fa1fb55fb7ba534ccf94599fd. The schema key should be added to that, and documented in the lib/CPAN/Testers/API.pm file.
Often we will want to change which database the API is pointing to. This could be for development or emergency management purposes. With the Schema module using [DBIx::Class::Schema::Config]() for configuration (see https://github.com/cpan-testers/cpantesters-schema/issues/3), we have an easy way to refer to known databases with a simple string. But, we should also provide a way to override the global database configs with our own local ones for flexibility and in case of emergency.
Using the Mojolicious Config plugin, create a section in the config called
schema
. This section should be a hash reference and contain the keys:database
, which is either a name of a database in theDBIx::Class::Schema::Config
configuration file or a full DBI data source name (DSN)user
, which is the user to connect with (or override the DBIC::Schema::Config user with)password
, which is the password to connect with (or override the DBIC::Schema::Config password with)args
, which is a hash reference of additional arguments to DBI (things likePrintError => 0
and the like), and which will likely be rarely used except to get some better debug loggingSince we install the API application via CPAN, we will need to either use the
MOJO_CONFIG
environment variable to point to the config file, or set theMOJO_HOME
to control where Mojolicious::Plugin::Config looks for configuration files. We will also likely need to set themoniker
of the CPAN::Testers::API application to something friendly likecpantesters-api
so that our configuration file name iscpantesters-api.conf
and/orcpantesters-api.$MOJO_MODE.conf
.