byrokrat / giroapp

Command line app for managing autogiro donations.
GNU General Public License v3.0
4 stars 2 forks source link

SQL data store #150

Open hanneskod opened 6 years ago

hanneskod commented 6 years ago

The json thing is good during development. As it is easy to inspect. But someting faster is needed in the future. Should probably be a choice between SQLite and MySQL..

hanneskod commented 6 years ago

Needs #160 first..

hanneskod commented 5 years ago

As of beta-5 we have giroapp.ini settings anticipating db adapters and pdo support:

; Database driver to use, currently only 'json' is supported
db_driver = json

; Data Source Name, the information required to connect to the database
; Values are driver specific
db_dsn = "%base_dir%/data"
hanneskod commented 5 years ago

There is now a set of interfaces defining the database layer. Implement these interfaces to add new database drivers. See the Db namespace. Also see the Json driver for an example.

Implementation agnostic tests are in DonorRepositorySpecTrait and ImportHistorySpecTrait. (See the json testsuite for reference.)

Also note that database drivers can be written as plugins using something like

use byrokrat\giroapp\Plugin\PluginInterface;
use byrokrat\giroapp\Plugin\EnvironmentInterface;

return new class implements PluginInterface {
    public function loadPlugin(EnvironmentInterface $env): void
    {
        $env->registerDatabaseDriver(new MyCustomDatabaseDriverFactory);
    }
};