kdbvis Compare the structure of old database and latest database structure and make required queries to migrate old database
- Create
kdbvdatabase- dbv database is a single file witch contains database structure
- its created using
makefunction
upgradefunction is Compare the contents of your old databases withkdbvfile ( witch contains latest database structure ) and Automate your data migrations from old to latest- using
queryfunction you can get all sql queries. that need to migrate database- its return array of queries
Give star to library if you like STAR++
- Upgrade - Database Upgrade
- Easy - Extremely easy to learn and use
PHP 5.3+ and PDO extension installed
This library is designed to be installed via Composer.
Add the dependency into your projects composer.json.
{
"require": {
"ganeshkandu/kdbv": "*"
}
}
Download the composer.phar
curl -sS https://getcomposer.org/installer | phpInstall the library.
php composer.phar installTo add in in your dependencies
php composer.phar require ganeshkandu/kdbvThis library requires an autoloader, if you aren't already using one you can include Composers autoloader.
require('vendor/autoload.php');- Create
kdbv databaseusingmakefunction of yourlatest database - deploy
kdbv databasewith your application - You can simply overwrite latest version of your application on your old version of application ( NOTES latest version is deployed with
kdbv databaseandkdbv library) - now you have your latest changed files with your old database which need to be update to new changes database structure
- now
upgradeyour database usingupgradefunction - ALL DONE ENJOY
- if you getting any issue create an issue
// Using kdbv namespace
namespace kanduganesh;
// just use this code to require auto loader on the top of your projects.
require 'vendor/autoload.php';
// Initialize
$obj = new kdbv(array(
'HOST' => '<mysql_host>',
'DATABASE' => '<mysql_database>',
'USER' => '<database_user>',
'PASS' => '<database_password>',
'PORT' => '<mysql_port>',
'KDBV' => '<kdbv_database_name>', //name of kdbv database
'PREFIX' => '<table prefix>', //table prefix
));
<kdbv_database_name>is a name ofkdbv databasewhich to be deploy with your application ( kdbv database contain database structure of your latest application )
use
$objof step 1
/*
Create kdbv database
notes :- during calling make function your mysql database should contain latest version database so it can store latest structure of database
*/
$obj->make();
use
$objof step 1
$sqls_queries = $obj->query();
foreach($sqls_queries as $query){
echo $query."\n";
}/*
upgrade mysql database
notes :- during calling upgrade function your kdbv database should be deployed with your application
Upgrade your old mysql database to your latest mysql database structure
*/
$obj->upgrade();- run
$obj->make();all time you when you release new application version with change database structure