PHPackages                             rafaeltheraven/db-changeset-manager-psql - 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. rafaeltheraven/db-changeset-manager-psql

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

rafaeltheraven/db-changeset-manager-psql
========================================

Automate the process of applying SQL files (changesets) to databases of different environments or users.

v0.3.6(4y ago)015MITPHPPHP &gt;=5.4.0

Since Apr 18Pushed 4y agoCompare

[ Source](https://github.com/Rafaeltheraven/db-changeset-manager-psql)[ Packagist](https://packagist.org/packages/rafaeltheraven/db-changeset-manager-psql)[ RSS](/packages/rafaeltheraven-db-changeset-manager-psql/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)DependenciesVersions (13)Used By (0)

What is this fork?
==================

[](#what-is-this-fork)

This is a very basic fork from the upstream zimzat version which makes this application work on postgres databases. I made it because I like this simplicity of their migrator, but I use postgres myself and they use some mysql specific syntax in some places.

To make autoincrement work I use some postgres specific syntax so it probably doesn't work anywhere else

Db Changeset Manager
====================

[](#db-changeset-manager)

Automate the process of applying SQL files (changesets) to databases of different environments or users.

Create versioned directories where developers can drop SQL files to be applied to other environments through the release process and back to other developers to ensure that everyone stays synced with database changes. This project doesn't try to force specific syntax, verbose declarations, or provide automated conflict resolution or detection; just a simple process of applying changes between environments.

A typical changeset directory would look something like this:

```
changesets
├── v1.0
│   ├── 20150102_create-user.sql
│   └── 20150103_track-user-actions.sql
├── v1.1
│   └── 20150103_track-user-action-date.sql
├── v1.3
│   ├── 2015-01-15_create-user-profile.sql
│   ├── 2015-01-16_blogs.sql
│   └── 2015-01-17_user-roles.sql
├── v1.3.1
│   └── 2015-01-20_add-user-roles.sql
└── v1.5
    ├── 2015-01-15_long-awaited-feature.sql
    ├── 2015-02-01_index-blogs.sql
    ├── 2015-02-03_add-reporting.sql
    └── 2015-02-10_blog-tags.sql

```

Changes are applied to the database in order of version number and then sorted numerically by file name, thus upgrading from 1.0 to 1.3 would apply 'track-user-actions' before 'track-user-action-date' even though they're the same date prefix.

By default directories should be prefixed with 'v' however this can be changed or eliminated by specifying the `versionPrefix` in the db.ini. The versioning scheme should otherwise follow the standard set out by [version\_compare()](http://php.net/version_compare).

Files must be suffixed with `.sql` and must be uniquely named between all versions but otherwise can be named anything. A natural sort (2 before 10) is done to the list of files before being applied to the database.

Restrictions
============

[](#restrictions)

- No SELECT statements.
- No CREATE DATABASE, DROP DATABASE, or USE DATABASE statements.

Requirements
============

[](#requirements)

- PDO
- Postgresql

Install
=======

[](#install)

The supported method to install the utility is through Composer.

```
composer install zimzat/db-changeset-manager

```

Command Line Usage
==================

[](#command-line-usage)

Once installed a php shell file can be used to apply changes from the command line.

```
ln -s ./vendor/bin/dbChangeManager.php .
./dbChangeManager.php

```

The command line tool expects a configuration file to be defined specifying the access name and permissions.

```
host = localhost
dbname = test
username = root
; password = secret
changesetPath = changesets
; versionPrefix = v

```

The available commands, which can also be seen by running the command without any options, are:

```
./bin/dbChangeManager.php -h
./bin/dbChangeManager.php -s [-c db.ini]
./bin/dbChangeManager.php -t  [-a | -n | -i | -o ] [-c db.ini]

Specify an action:
  -h           Display this help message.
  -s           Display the current version of the database
  -t version   Specify new version to target upgrade to

Set a run mode:
  -a           Apply: Execute all changesets and tracking against the database immediately
  -n           No Op: Run as normal but perform no modifying operations against the database.
  -i           Interactive: Provide interactive confirmation prompts before applying changes.
  -o file      File: Output all SQL commands to a file which can be run separately.

Other options:
  -c file      Specify the db config file to use, defaults to db.ini

```

PHP Usage
=========

[](#php-usage)

The utility can also be invoked directly from a PHP script by instantiating the \\DbVcs\\ChangeManager object with its dependencies.

```
$changeManager = new \DbVcs\ChangeManager(
	'changesets',
	new \PDO(
		'mysql:host=localhost;dbname=test',
		'root',
		null, [
			\PDO::ATTR_EMULATE_PREPARES => false,
			\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION,
		]
	),
	new \DbVcs\Processor\Apply(),
	new \DbVcs\Output()
);
$version = null;

$changeManager->updateTo($version);

```

Note: The \\DbVcs\\Output class should be extended to send results where and how desired (log file, browser, database, etc).

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 80.6% 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 ~227 days

Recently: every ~607 days

Total

12

Last Release

1546d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2dbea615a87ab34a655c745b444931a361f2c7b91f6404eb6f8350c4e8a7988c?d=identicon)[rafaeltheraven](/maintainers/rafaeltheraven)

---

Top Contributors

[![zimzat](https://avatars.githubusercontent.com/u/3887134?v=4)](https://github.com/zimzat "zimzat (25 commits)")[![Rafaeltheraven](https://avatars.githubusercontent.com/u/10010899?v=4)](https://github.com/Rafaeltheraven "Rafaeltheraven (6 commits)")

### Embed Badge

![Health badge](/badges/rafaeltheraven-db-changeset-manager-psql/health.svg)

```
[![Health](https://phpackages.com/badges/rafaeltheraven-db-changeset-manager-psql/health.svg)](https://phpackages.com/packages/rafaeltheraven-db-changeset-manager-psql)
```

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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