-
Notifications
You must be signed in to change notification settings - Fork 33
PHP database migration
alwex edited this page May 30, 2012
·
17 revisions
- Introduction
- Installation
2.1. Project initialisation
2.2. Customizing configuration
- Generating a migration script
- Migrating UP and DOWN
4.1 Migrating UP
4.2 Migrating DOWN
4.3 Force a unique migration
4.4 Make migrations transactional
- Migrations status
- Dealing with environements
PHP database migration is a small utility inspired by two great migration tool called MyBatis and Rails rake that allow to easily maintain database schema on multiple environments without much effort.
Just clone the git repository somewhere on the project folder (each installation maintain one project).
git clone git://github.com/alwex/php-database-migration.git
execute the following comand
./migrate --init --driver=pgsql --database=my_dev_database --host=my_dev_db_host --login=my_db_login --password=my_password --changelog=changelog
explanation
--driver => PDO supported driver --database => the name of the development database --host => the hostname where is located the development database --login => database login --password => database password --changelog => changelog and versioning table recording migrations
It will output
======= Initialization =======
Configuration files created:
./environments
|----development.ini
|----preproduction.ini
`----production.ini
Migration directory created:
./migrations
You may modify the environemnts configuration files
and create the changelog table changelog
create table changelog (id numeric(20,0), applied_at character varying(25), description character varying(255));