PHP Classes

kdbv: Tool to migrate MySQL schema to MySQL database

Recommend this page to a friend!
  Info   View files Documentation   View files View files (11)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 88 All time: 9,970 This week: 455Up
Version License PHP version Categories
kdbv 1.0Custom (specified...5PHP 5, Databases, Systems administration


This package implements a tool to migrate MySQL schema to another MySQL database.

It encapsulates each change done to a database in database migration file.

Then the class may execute the necessary steps to perform the deployment necessary for the migration on a production database.

Picture of Ganesh Kandu
  Performance   Level  
Name: Ganesh Kandu <contact>
Classes: 4 packages by
Country: India India
Age: ???
All time rank: 3036190 in India India
Week rank: 286 Up21 in India India Up
Innovation award
Innovation award
Nominee: 2x


mysql database auto schema migration tool

`kdbv library` migrations between versions of a application.


> upgrade your mysql database to current latest version from older version

Common DB versioning problems

  • Where should I keep track of schema changes?
  • What changed since last production push?
  • Did I apply this patch already to this server?
  • Did I run the migrations on this copy of the app?
  • Did I run the update script after updating the schema?

How kdbv library helps

  • Each DB change encapsulated in a single migration ```kdbv database file```
  • Deployment script automatically runs all necessary migration sql queries on production database immediately after code deploys
  • Nothing to remember / eliminates human factor
  • Easy to test, easy to reproduce
  • A ```kdbv library``` is code that changes the database structure between versions

How its works

Like the source files in our project,the database is constantly changing too. That?s why we also need a way to track the changes of database versioning but using `kdbv` you don't need to keep track of changes just run make to create `kdbv database` and deploy with your latest change and run `update` function to change database automatically database upgraded thats is it

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

Get Started


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 | php

Install the library.

php composer.phar install


> To add in in your dependencies

php composer.phar require ganeshkandu/kdbv

Auto loading

This library requires an autoloader, if you aren't already using one you can include Composers autoloader.



steps to perform

  • Create ```kdbv database``` using ```make``` function of your ```latest database```
  • deploy ```kdbv database``` with your application
  • You can simply overwrite latest version of your application on your old version of application ( NOTES latest version is deployed with ```kdbv database``` and ```kdbv library``` )
  • now you have your latest changed files with your old database which need to be update to new changes database structure
  • now ```upgrade``` your database using ```upgrade``` function
  • if you getting any issue create an issue

step 1

Instantiate & load()

// 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 of `kdbv database` which to be deploy with your application ( _kdbv database contain database structure of your latest application_ )

step 2

> use `$obj` of step 1

create `kdbv database`

Create kdbv database
notes :- during calling make function your mysql database should contain latest version database so it can store latest structure of database 

step 3

> use `$obj` of step 1

Get Mysql Upgrade Queries

$sqls_queries = $obj->query();
foreach($sqls_queries as $query){
    echo $query."\n";


Upgrade mysql database

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

Best practices

  • run ```$obj->make();``` all time you when you release new application version with change database structure


  Files folder image Files  
File Role Description
Files folder image.github (2 files)
Files folder imagesrc (5 files)
Accessible without login Plain text file .htaccess Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE.txt Lic. License
Accessible without login Plain text file Doc. Documentation

  Files folder image Files  /  .github  
File Role Description
  Accessible without login Plain text file Data Auxiliary data
  Accessible without login Image file kdbv.png Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
  Accessible without login Plain text file .htaccess Data Auxiliary data
  Plain text file btree.php Class Class source
  Plain text file db.php Class Class source
  Plain text file kdbv.php Class Class source
  Plain text file table.php Class Class source

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:9,970
This week:455Up