PHPackages                             ganeshkandu/kdbv - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. ganeshkandu/kdbv

ActiveLibrary[Database &amp; ORM](/categories/database)

ganeshkandu/kdbv
================

mysql database auto schema migration tool

1.0.7(7y ago)931632GPL-3.0PHPPHP &gt;=5.3.0

Since Dec 2Pushed 7y ago1 watchersCompare

[ Source](https://github.com/GaneshKandu/kdbv)[ Packagist](https://packagist.org/packages/ganeshkandu/kdbv)[ RSS](/packages/ganeshkandu-kdbv/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (8)DependenciesVersions (9)Used By (2)

mysql database auto schema migration tool
=========================================

[](#mysql-database-auto-schema-migration-tool)

[![](https://github.com/GaneshKandu/kdbv/raw/master/.github/kdbv_image.png)](https://github.com/GaneshKandu/kdbv/blob/master/.github/kdbv_image.png)

how it works
------------

[](#how-it-works)

> `kdbv` is Compare the structure of old database and latest database structure and make required queries to migrate old database

- Create `kdbv` database
    - dbv database is a single file witch contains database structure
    - its created using `make` function
- `upgrade` function is Compare the contents of your old databases with `kdbv` file ( witch contains latest database structure ) and Automate your data migrations from old to latest
- using `query` function you can get all sql queries. that need to migrate database
    - its return array of queries

#### Give star to library if you like **[STAR++](https://github.com/GaneshKandu/kdbv/stargazers)**

[](#give-star-to-library-if-you-like-star)

Features
--------

[](#features)

- **Upgrade** - Database Upgrade
- **Easy** - Extremely easy to learn and use

Requirement
-----------

[](#requirement)

PHP 5.3+ and PDO extension installed

Get Started
-----------

[](#get-started)

### Installation

[](#installation)

This library is designed to be installed via [Composer](https://getcomposer.org/doc/).

Add the dependency into your projects composer.json.

```
{
  "require": {
    "ganeshkandu/kdbv": "*"
  }
}

```

Download the composer.phar

```
curl -sS https://getcomposer.org/installer | php
```

Install the library.

```
php composer.phar install
```

#### or

[](#or)

> To add in in your dependencies

```
php composer.phar require ganeshkandu/kdbv
```

Auto loading
------------

[](#auto-loading)

This library requires an autoloader, if you aren't already using one you can include [Composers autoloader](https://getcomposer.org/doc/01-basic-usage.md#autoloading).

```
require('vendor/autoload.php');
```

Usage
-----

[](#usage)

### steps to perform

[](#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
- **ALL DONE ENJOY**
- if you getting any issue [create an issue](https://github.com/GaneshKandu/kdbv/issues)

### step 1

[](#step-1)

#### Instantiate &amp; load()

[](#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' => '',
	'DATABASE' => '',
	'USER' => '',
	'PASS' => '',
	'PORT' => '',
	'KDBV' => '', //name of kdbv database
	'PREFIX' => '', //table prefix
));
```

> `` is a name of `kdbv database` which to be deploy with your application ( *kdbv database contain database structure of your latest application* )

### step 2

[](#step-2)

> use `$obj` of step 1

#### create `kdbv database`

[](#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
*/
$obj->make();

```

### step 3

[](#step-3)

> use `$obj` of step 1

#### Get Mysql Upgrade Queries

[](#get-mysql-upgrade-queries)

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

or
--

[](#or-1)

### Upgrade mysql database

[](#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
*/
$obj->upgrade();
```

Best practices
--------------

[](#best-practices)

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

#### Maintainers

[](#maintainers)

- [Ganesh Kandu](https://github.com/GaneshKandu)
    - [Google+](https://plus.google.com/u/0/+ganeshkandu)
    - [Linkedin](https://www.linkedin.com/in/ganesh-kandu-42b14373/)
    - [EMail](mailto:kanduganesh@gmail.com)
    - [Follow](https://github.com/GaneshKandu)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~34 days

Recently: every ~58 days

Total

8

Last Release

2847d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/030a8f178b8894188fb2d3b5342187da37a514f7bc8ac231312cd74dcd038ee4?d=identicon)[GaneshKandu](/maintainers/GaneshKandu)

---

Tags

autodeployautomationcomposerdatadatabasedatabase-migrationslatest-versionmariadbmigrations-generatormysqlmysql-databasephpschemaseedupdateupgradeupgrade-toolversion-changerversion-controlversioningphpcomposerschemaautomationdatadatabasemysqlmariadbdatabase migrationsversioningupgradeupdateversion controlpackagistautodeploymysql-databaseupgrade-toolversion-changerlatest-version

### Embed Badge

![Health badge](/badges/ganeshkandu-kdbv/health.svg)

```
[![Health](https://phpackages.com/badges/ganeshkandu-kdbv/health.svg)](https://phpackages.com/packages/ganeshkandu-kdbv)
```

###  Alternatives

[ifsnop/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k5.5M69](/packages/ifsnop-mysqldump-php)[clouddueling/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k22.9k](/packages/clouddueling-mysqldump-php)[druidfi/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

35489.8k6](/packages/druidfi-mysqldump-php)[smrtr/mysql-version-control

A crude version control system for mysql written in php

221.4k](/packages/smrtr-mysql-version-control)[popphp/pop-db

Pop Db Component for Pop PHP Framework

1814.6k11](/packages/popphp-pop-db)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
