Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kohkimakimoto/phpmigrate
PHPMigrate is a minimum database migration tool for MySQL.
https://github.com/kohkimakimoto/phpmigrate
Last synced: about 2 months ago
JSON representation
PHPMigrate is a minimum database migration tool for MySQL.
- Host: GitHub
- URL: https://github.com/kohkimakimoto/phpmigrate
- Owner: kohkimakimoto
- Created: 2013-03-28T09:30:45.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-06-19T02:42:37.000Z (over 11 years ago)
- Last Synced: 2024-05-29T16:43:43.147Z (4 months ago)
- Language: PHP
- Size: 237 KB
- Stars: 13
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# PHPMigrate
PHPMigrate is a minimum database migration tool for MySQL.
Uses plain SQL to change schema. And runs some PHP codes post and previous executing SQL.
**This software was restructured to [LibMigration](https://github.com/kohkimakimoto/lib-migration) to use easily in other PHP products.**
## Requrement
* PHP5.x or later (Probably).
## Installation
Just puts `migrate.php` file in your direcotry.
wget https://raw.github.com/kohkimakimoto/phpmigrate/master/migrate.php
## Getting Started
Configure to connect your MySQL database to migrate.
Please open `migrate.php` downloaded. And modify below settings for your environment.
$database_config = array(
// Database settings.
'yourdatabase' => array(
// PDO Connection settings.
'database_dsn' => 'mysql:dbname=yourdatabase;host=localhost',
'database_user' => 'user',
'database_password' => 'password',// schema version table
'schema_version_table' => 'schema_version'
),or
$database_config = array(
// Database settings.
'yourdatabase' => array(
// mysql client command settings.
'mysql_command_enable' => true,
'mysql_command_cli' => "/usr/bin/mysql",
'mysql_command_tmpsqldir' => "/tmp",
'mysql_command_host' => "localhost",
'mysql_command_user' => "user",
'mysql_command_password' => "password",
'mysql_command_database' => "yourdatabase",
'mysql_command_options' => "--default-character-set=utf8",// schema version table
'schema_version_table' => 'schema_version'
),Difference between settings of `database_xxx` and `mysql_command_xxx` is database connection to execute SQL.
At default, it uses `database_xxx` settings to connect database using PDO.
You set up that `mysql_command_enable` is **true**. It uses `mysql_command_xxx` settings to connect databse using mysql client command.
If you use `delimeter` command in your SQL. You need to use `mysql_command_xxx` settings. Because `delimeter` command is not a SQL.
It's a mysql client command.And create migration class file. Run the following command
php migrate.php create create_sample_table
You would get the following messages and the skeleton migration file.
`20130422155835` timestamp part depeneds on your environment.Created 20130422155835_create_sample_table.php
Open the `20130422155835_create_sample_table.php`. And modify `getUpSQL` and `getDownSQL` method like below.
/**
* Return the SQL statements for the Up migration
*
* @return string The SQL string to execute for the Up migration.
*/
public function getUpSQL()
{
return <<