garrcomm / easy-migrations
Easy database migrations
Requires
- php: >=7.3
Requires (Dev)
- phpstan/phpstan: ^1.10
- squizlabs/php_codesniffer: ^3.5
Suggests
- ext-mysqli: Required when using mysqli as engine
This package is auto-updated.
Last update: 2024-11-10 10:20:26 UTC
README
For simpler applications with a database, complicated ORM like migrations are overkill, but database versioning is still very useful.
For that purpose, I created this package.
Configuration file
The configuration file is in ini format.
There are a few default locations where configuration files should be located.
It's also possible to specify a config file with the --config-file [path]
argument,
or by specifying a specific config value with the --config [key] [value]
argument.
If more then one config file is found and/or specified, they will be loaded in this sequence:
- migrator.ini.dist in the current working directory
- migrator.ini in the current working directory
- migrator.ini.dist in the current working directory plus "/config/"
- migrator.ini in the current working directory plus "/config/"
- migrator.ini.dist in the directory containing the migrator executable
- migrator.ini in the directory containing the migrator executable
- All config files specified by
--config-file [path]
- All flags specified by
--config [key] [value]
A config file can look like this:
[migrator]
; The path (relative from the configuration file) and namespace in which migrations will be added
path = app/migrations
;namespace = Migrations
; Default chmod for folders
;path_attr = 0755
; Default chmod for files
;file_attr = 0644
; Can be mysqli, maybe more implementations will be added in the future
engine = mysqli
; MySQLi connection info
hostname = localhost
username = root
password = rootroot
database = mydatabase
port = 3306
;socket = /var/run/mysqld.sock
; Name of the versioning table
;version_table = _migration_versions
Sections other than [migrator]
are ignored and values added with --config [key] [value]
are interpreted as if they existed in the [migrator]
section.
Values that are commented out in the example above are default values.