PHPackages                             smrtr/mysql-version-control - 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. smrtr/mysql-version-control

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

smrtr/mysql-version-control
===========================

A crude version control system for mysql written in php

1.3.0(9y ago)221.4k2MITPHP

Since Feb 12Pushed 9y ago4 watchersCompare

[ Source](https://github.com/smrtr/mysql-version-control)[ Packagist](https://packagist.org/packages/smrtr/mysql-version-control)[ RSS](/packages/smrtr-mysql-version-control/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (10)Dependencies (3)Versions (13)Used By (0)

mysql-version-control
=====================

[](#mysql-version-control)

Effective mysql database version control in one library. Quick and simple to use, but with a rich and flexible API for those who want to customise the set up.

Requirements
------------

[](#requirements)

- PHP &gt;= 5.4
- Composer
- MySQL client

Install with composer:

```
$ composer require smrtr/mysql-version-control:~1.0

```

Versioning
==========

[](#versioning)

Your database versions will be stored in `/db/versions` by default. The sql for each version is stored in a directory directly under this directory. So the directories are named `db/versions/1`, `db/versions/2` and so on. Each version must contain at least one of the following files:

- `schema.sql` - always runs first, contains `CREATE TABLE IF NOT EXISTS` and `ALTER` statements and the like.
- `data.sql` - contains `REPLACE INTO`, `INSERT`, `UPDATE` and `DELETE` statements and the like.
- `testing.sql` - same as `data.sql` but with test data which doesn't need to exist outside of testing environments.
- `runme.php` - a custom php hook for running php code with your version.

The files for each version are run in the order specified above.

Configuration
=============

[](#configuration)

The quickest way to get started is to set up your database configuration in a file at `/db/db.ini`.

See *examples/db.ini* for an example of this file.

### Environments

[](#environments)

Define a list of environments and testing environments under the tag `[environments]`.

List out all of the available environments with entries like so: `environments[] = "local-dev"`.

List the testing environments like so: `testing_environments[] = "local-dev"`. This list is a subset of the environments list and comprises those environments which should receive test data.

### Connections

[](#connections)

You must define two database connection configurations for each environment. The two configurations are called `buildtime` and `runtime` and they are used for processing schema changes and data changes respectively.

Each connection requires a `host`, `user`, `password` and `database`. You can optionally add a `port`.

Command Line Interface
======================

[](#command-line-interface)

The command line tool is located at `vendor/bin/smyver.php`.

*Remember it!* It stands for **S**mrtr **MY**sql **VER**sion control.

status
------

[](#status)

Run `vendor/bin/smyver.php status ` to get the current status of the database for that environment.

up
--

[](#up)

Run `vendor/bin/smyver.php up ` to install or update the database on the given environment. This command looks at the available versions in the `db/versions` directory and applies new versions sequentially from the current version.

If this is the first run on the given environment, then a table called `db_config` is created and used to store the current database version.

You may optionally provide a second argument specifying the mysql client binary to use. This argument is required if mysql is not on your $PATH.

#### `--no-schema`

[](#--no-schema)

Use this flag to skip the schema files. This can be useful if you use an ORM to build the database schema.

#### `--install-provisional-version`

[](#--install-provisional-version)

Use this flag to install a provisional version. This allows you to test out your database version, which may currently be in development, before you commit to it by giving it a version number. This command looks for your provisional version in `/db/versions/new` by default.

teardown
--------

[](#teardown)

Run `vendor/bin/smyver.php teardown ` to tear down the tables on the given environment.

This command is useful for development &amp; testing environments.

Use the `confirm` option to bypass the confirmation prompt, e.g.

```
vendor/bin/smyver.php  --confirm

```

Global CLI options
------------------

[](#global-cli-options)

These options can be used with all console commands.

#### `--config-adapter`

[](#--config-adapter)

Specify a configuration adapter to use instead of the Ini adapter which is used by default.

If you are using one of the standard adapters shipped with this package you only need to enter the class name, e.g. PhpFile.

If you are using your own custom adapter class then you must provide a fully qualified class name and your class must implement `Smrtr\MysqlVersionControl\DbConfigAdapter\ConfigAdapterInterface`.

#### `--config-adapter-param`

[](#--config-adapter-param)

You can specify one or more constructor parameters for the configuration adapter class with this option.

To specify multiple parameters simply use the option more than once, e.g. `--config-adapter-param="One" --config-adapter-param="Two"`would result in the configuration adapter being instantiated like so: `new $adapter("One", "Two")`.

#### `--provisional-version`

[](#--provisional-version)

Use this option to provide a custom path to your provisional version. Your custom path is relative to the versions path.

#### `--versions-path`

[](#--versions-path)

Use this option, or `-p` for short, to provide a custom path to your versions. This allows you to override the default versions path which is `/db/versions`. If the path provided is not an absolute path then it is assumed to be relative to the project root.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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 ~81 days

Recently: every ~125 days

Total

12

Last Release

3584d ago

Major Versions

0.6 → 1.0.02014-02-14

### Community

Maintainers

![](https://www.gravatar.com/avatar/a1ce943f5c99a0be65b726975e3c3d2898dfbdbcf07aa5525f39bd32ac9e8279?d=identicon)[joegreen88](/maintainers/joegreen88)

---

Top Contributors

[![joegreen88](https://avatars.githubusercontent.com/u/1363420?v=4)](https://github.com/joegreen88 "joegreen88 (93 commits)")

---

Tags

command-line-tooldatabase-managementdatabase-schemadatabase-schema-migrationdatabase-schemasdatabase-testingmigrationsmysqlphpversion-controlmigrationdatadatabasemysqldbstructureversionupdateversion control

### Embed Badge

![Health badge](/badges/smrtr-mysql-version-control/health.svg)

```
[![Health](https://phpackages.com/badges/smrtr-mysql-version-control/health.svg)](https://phpackages.com/packages/smrtr-mysql-version-control)
```

###  Alternatives

[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4572.9M34](/packages/aura-sqlquery)[atlas/query

Object-oriented query builders and performers for MySQL, Postgres, SQLite, and SQLServer.

41249.0k7](/packages/atlas-query)[camcima/php-mysql-diff

14842.6k](/packages/camcima-php-mysql-diff)[davmixcool/php-dbcloud

Easily backup PostgreSql or MySql database to the cloud

111.5k](/packages/davmixcool-php-dbcloud)

PHPackages © 2026

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