33[ ![ SensioLabsInsight] ( https://insight.sensiolabs.com/projects/571cb412-7018-4938-a4e5-0f9ce44956d7/mini.png )] ( https://insight.sensiolabs.com/projects/571cb412-7018-4938-a4e5-0f9ce44956d7 )
44[ ![ Build Status] ( https://travis-ci.org/byjg/migration.svg?branch=master )] ( https://travis-ci.org/byjg/migration )
55
6- A micro framework in PHP for managing a set of database migrations using pure Sql .
6+ Simple library in PHP for database version control. Supports Sqlite, MySql, Sql Server and Postgres .
77
88Database Migration is a set of commands for upgrade or downgrade a database.
99This library uses only SQL commands.
@@ -66,6 +66,25 @@ For example: 00002.sql is the script for move the database from version '1' to '
6666For example: 00001.sql is the script for move the database from version '2' to '1'.
6767The "down" folder is optional.
6868
69+ ### Multi Development environment
70+
71+ If you work with multiple developers and multiple branches it is to difficult to determine what is the next number.
72+
73+ In that case you have the suffix "-dev" after the version number.
74+
75+ See the scenario:
76+
77+ - Developer 1 create a branch and the most recent version in e.g. 42.
78+ - Developer 2 create a branch at the same time and have the same database version number.
79+
80+ In both case the developers will create a file called 43-dev.sql. Both developers will migrate UP and DOWN with
81+ no problem and your local version will be 43.
82+
83+ But developer 1 merged your changes and created a final version 43.sql (` git mv 43-dev.sql 43.sql ` ). If the developer 2
84+ update your local branch he will have a file 43.sql (from dev 1) and your file 43-dev.sql.
85+ If he is try to migrate UP or DOWN
86+ the migration script will down and alert him there a TWO versions 43. In that case, developer 2 will have to update your
87+ file do 44-dev.sql and continue to work until merge your changes and generate a final version.
6988
7089## Running in the command line
7190
@@ -76,9 +95,12 @@ Usage:
7695 command [options] [arguments]
7796
7897Available commands:
98+ create Create the directory structure FROM a pre-existing database
99+ install Install or upgrade the migrate version in a existing database
79100 down Migrate down the database version.
80101 reset Create a fresh new database
81102 up Migrate Up the database version
103+ version Get the current database version
82104
83105Arguments:
84106 connection The connection string. Ex. mysql://root:password@server/database [default: false]
@@ -91,7 +113,7 @@ Example:
91113 migrate down --up-to=3 --path=/somepath mysql://root:password@server/database
92114```
93115
94- ## Suportted databases:
116+ ## Supported databases:
95117
96118* Sqlite
97119* Mysql / MariaDB
@@ -101,7 +123,7 @@ Example:
101123## Installing Globally
102124
103125``` bash
104- composer global require ' byjg/migration=1.1 .*'
126+ composer global require ' byjg/migration=2.0 .*'
105127sudo ln -s $HOME /.composer/vendor/bin/migrate /usr/local/bin
106128```
107129
@@ -112,8 +134,8 @@ This library has integrated tests and need to be setup for each database you wan
112134Basiclly you have the follow tests:
113135
114136```
115- phpunit tests/SqliteCommandTest .php
116- phpunit tests/MysqlCommandTest .php
117- phpunit tests/PostgresCommandTest .php
118- phpunit tests/SqlServerCommandTest .php
137+ phpunit tests/SqliteDatabaseTest .php
138+ phpunit tests/MysqlDatabaseTest .php
139+ phpunit tests/PostgresDatabaseTest .php
140+ phpunit tests/SqlServerDatabaseTest .php
119141```
0 commit comments