-
Notifications
You must be signed in to change notification settings - Fork 13
Configuration
DbPatch has some parameters that can be configured by the user in different type of configuration files. In the next chapters we will use the ini configuration file, but it's also possible to write a XML or PHP configuration file.
An overview will be given in this chapter where you could place the configuration file and what it needs to look like.
The best solution would be to place the configuration file in the root of your project with the name: dbpatch.ini. This file can be committed to a Revision Control System and thus will the settings always be available. When you have added a configuration file then you do not need to provide its location to Dbpatch; the following command suffices to give you the status of your database patches:
$ dbpatch
Another option is to use the --config argument to tell DbPatch the location of your configuration file. This can be convenient for centralized configuration management or using different settings per environment.
DbPatch follows the convention over configuration style and as such it is only necessary to specify the options which you want to change with regard to the defaults.
The easiest way to find out what the defaults are is to look in the configuration template, which is located in [DBPATCH FOLDER]/docs/dbpatch.tpl.ini or to examine the specifications in this document. Usually the following configuration suffices for your project
[dbpatch]
; database settings
db.adapter = Mysqli
db.params.host = "localhost"
db.params.username = "user"
db.params.password = "pass"
db.params.dbname = "db"
db.params.charset = "utf8"
db.params.bin_dir =
The last setting can be used to specify a custom directory where DbPatch can find the binaries.
Extra settings that can be added are:
limit = 10
To set the limit of latest patches you want to show;
default_branch = default
The default branch that is used;
patch_directory = database/patches
Location of the patch files, default it will look for 'database/patches' in the directory where the script is executed;
patch_prefix = patch
The prefix name of the patch files, see also the naming convention of patch files;
color = true
This will add some color to the output.
dump_before_update = true
This will create a database before it will apply any patches.
[dbpatch]
limit = 10
default_branch = default
patch_directory = ../patches
patch_prefix = patch
color = false
dump_before_update = false
; database settings
db.adapter = Mysqli
db.params.host = "localhost"
db.params.username = "user"
db.params.password = "pass"
db.params.dbname = "db"
db.params.charset = "utf8"
db.params.bin_dir =
TODO
<?php
$dbPatchConfig = array(
'limit' => 10,
'default_branch' => 'default',
'patch_directory' => 'database/patches',
'patch_prefix' => 'patch',
'color' => false,
'dump_before_update'=> false,
'dump_directory' => '',
# database settings
'db' => array(
'adapter' => 'Mysqli',
'params' => array(
'host' => 'localhost',
'username' => 'user',
'password' => 'pass',
'dbname' => 'db',
'charset' => 'utf8',
'bin_dir' => '',
)),
);