11PhpDbMigration - full PHP database migration tool
22=================================================
33
4- This is a full standalone PHP tool based on symfony console and inspired by the rails database migration tool and MyBatis.
5- It merge the functionnality of the two tools and has been desined to be as flexible as possible.
4+ This is a full standalone PHP tool based on [ Symfony Console] ( http://symfony.com/doc/current/components/console )
5+ and inspired by the Rails database migration tool and MyBatis. It merges the functionality of the two tools and
6+ has been designed to be as flexible as possible.
7+
8+ Usage
9+ -----
10+ ```
11+ $ ./bin/migrate
12+ Console Tool
13+
14+ Usage:
15+ command [options] [arguments]
16+
17+ Options:
18+ -h, --help Display this help message
19+ -q, --quiet Do not output any message
20+ -V, --version Display this application version
21+ --ansi Force ANSI output
22+ --no-ansi Disable ANSI output
23+ -n, --no-interaction Do not ask any interactive question
24+ -v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
25+
26+ Available commands:
27+ help Displays help for a command
28+ list Lists commands
29+ migrate
30+ migrate:addenv Initialise an environment to work with php db migrate
31+ migrate:create Create a SQL migration
32+ migrate:down Rollback all waiting migration down to [to] option if precised
33+ migrate:init Create the changelog table on your environment database
34+ migrate:status Display the current status of the specified environment
35+ migrate:up Execute all waiting migration up to [to] option if precised
36+ ```
637
738Installing it to your project
839-----------------------------
@@ -30,19 +61,29 @@ Adding an environment
3061---------------------
3162The first thing to do before playing with SQL migrations is to add an environment, let's add the dev one.
3263
33- ![ alt tag] ( http://tikotepadventure.com/files/php-database-migration/addenv.gif )
64+ ```
65+ $ ./bin/migrate migrate:addenv
66+ ```
67+
68+ You will be prompted to answer a series of questions about your environment, and then a config file will be saved
69+ in ` ./.php-database-migration/environments/[env].yml ` .
3470
3571Initialization
3672--------------
37- Once the environment is added, you have to initialize it (create the changelog table on the good database)
73+ Once the environment is added, you have to initialize it. This verifies that the database connection works, and
74+ create a new database table for tracking the current database changes:
3875
39- ![ alt tag] ( http://tikotepadventure.com/files/php-database-migration/init.gif )
76+ ```
77+ $ ./bin/migrate migrate:init [env]
78+ ```
4079
4180Create a migration
4281------------------
4382It is time to create our first migration file.
4483
45- ![ alt tag] ( http://tikotepadventure.com/files/php-database-migration/create.gif )
84+ ```
85+ $ ./bin/migrate migrate:create [env]
86+ ```
4687
4788Migrations file are like this
4889
@@ -54,14 +95,21 @@ Migrations file are like this
5495 drop table users;
5596
5697Up and down
57- ------------------
98+ -----------
5899You can now up all the pending migrations. If you decided to down a migration, the last one will be downed alone to prevent from mistake. You will be asked to confirm the downgrade of your database before runing the real SQL script.
59- ![ alt tag] ( http://tikotepadventure.com/files/php-database-migration/status.gif )
60100
61- For developement purpose, it is also possible to up a single migration without taking care of the other ones.
101+ ```
102+ $ ./bin/migrate migrate:up [env]
103+ ```
104+
105+ For developement purpose, it is also possible to up a single migration without taking care of the other ones:
62106
63- ![ alt tag] ( http://tikotepadventure.com/files/php-database-migration/uponly.gif )
107+ ```
108+ $ ./bin/migrate migrate:up [env] --only=[migration]
109+ ```
64110
65- Same thing for down
111+ Same thing for down:
66112
67- ![ alt tag] ( http://tikotepadventure.com/files/php-database-migration/downonly.gif )
113+ ```
114+ $ ./bin/migrate migrate:down [env] --only=[migration]
115+ ```
0 commit comments