Download the PHP package vgarvardt/zf-simple-migrations without Composer
On this page you can find all versions of the php package vgarvardt/zf-simple-migrations. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download vgarvardt/zf-simple-migrations
More information about vgarvardt/zf-simple-migrations
Files in vgarvardt/zf-simple-migrations
Package zf-simple-migrations
Short Description Module for database migrations management.
License BSD-3-Clause
Homepage https://github.com/vgarvardt/ZfSimpleMigrations
Informations about the package zf-simple-migrations
ZfSimpleMigrations
Simple Migrations for Zend Framework 2. Project originally based on ZendDbMigrations but module author did not response for issues and pull-requests so fork became independent project.
Supported Drivers
The following DB adapter drivers are supported by this module.
- Pdo_Sqlite
- Pdo_Mysql
- Pdo_Pgsql
- Mysqli _only if you configure the driver options with
'buffer_results' => true
_
Installation
Using composer
add ZfSimpleMigrations
to the modules
array in application.config.php
Usage
Available commands
migration version [<name>]
- show last applied migration (name
specifies a configured migration)migration list [<name>] [--all]
- list available migrations (all
includes applied migrations)migration apply [<name>] [<version>] [--force] [--down] [--fake]
- apply or rollback migrationmigration generate [<name>]
- generate migration skeleton class
Migration classes are stored in /path/to/project/migrations/
dir by default.
Generic migration class has name Version<YmdHis>
and implement ZfSimpleMigrations\Library\MigrationInterface
.
Migration class example
Multi-statement sql
While this module supports execution of multiple SQL statements it does not have way to detect if any other statement
than the first contained an error. It is highly recommended you only provide single SQL statements to addSql
at a
time. I.e instead of
You should use
Accessing ServiceLocator In Migration Class
By implementing the Zend\ServiceManager\ServiceLocatorAwareInterface
in your migration class you get access to the
ServiceLocator used in the application.
Accessing Zend Db Adapter In Migration Class
By implementing the Zend\Db\Adapter\AdapterAwareInterface
in your migration class you get access to the Db Adapter
configured for the migration.
Configuration
User Configuration
The top-level key used to configure this module is migrations
.
Migration Configurations: Migrations Name
Each key under migrations
is a migrations configuration, and the value is an array with one or more of the following
keys.
Sub-key: dir
The path to the directory where migration files are stored. Defaults to ./migrations
in the project root dir.
Sub-key: namespace
The class namespace that migration classes will be generated with. Defaults to ZfSimpleMigrations\Migrations
.
Sub-key: show_log
(optional)
Flag to log output of the migration. Defaults to true
.
Sub-key: adapter
(optional)
The service alias that will be used to fetch a Zend\Db\Adapter\Adapter
from the service manager.