PHPackages                             zeptech/dbup - 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. zeptech/dbup

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

zeptech/dbup
============

Database update helper

1115PHP

Since Dec 17Pushed 11y ago1 watchersCompare

[ Source](https://github.com/pgraham/dbup)[ Packagist](https://packagist.org/packages/zeptech/dbup)[ RSS](/packages/zeptech-dbup/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (2)Used By (0)

Database Updater
================

[](#database-updater)

Database version manager written in PHP

Phases
------

[](#phases)

The update algorithm supports 3 phases for each schema revision, pre-alter, alter and post-alter. Pre-alter and post-alter scripts are PHP scripts. The alter phase is an SQL script. Each phase can return data which will be passed to subsequent phases including from PHP to SQL and vice versa (more on this later).

### **WIP** PHP Script execution methods

[](#wip-php-script-execution-methods)

DbUp supports a couple of different ways of structuring/encapsulating PHP pre/post alter scripts. The default simply requires the PHP files containing the alter logic. These files can be structured whichever way best suits the logic being performed. The return values from the pre-alter script is passed into the subsequent alter SQL script.

File system structure
---------------------

[](#file-system-structure)

Database schema revisions should all be stored in the same directory. Each revision will consist of a set of 1 to 3 files, one for phase where all phases are optional. The files need to named according to the following convention:

- Pre-alter: pre-alter-000001.php
- Alter: alter-000001.sql
- Post-alter: post-alter-000001.php

SQL Enhancements
----------------

[](#sql-enhancements)

The .sql scripts of the alter phase support a superset of SQL syntax. The additional syntax makes it eaiser to write portable scripts, as well as to perform some common tasks that would normally require a pre/post alter script.

### INSERT ID variables

[](#insert-id-variables)

When performing INSERTs into tables that contain a serial (auto increment) field it is difficult to determine the generated ID for subsequent use. DbUp supports special syntax to store these IDs in variables and to use them in subsequent INSERT statements. To store the insert ID use the following syntax:

```
my_insert_id := INSERT INTO my_table (key, value)
    VALUES ('aKey', 'aValue');

```

To then use the saved insert ID in a subsequent statement, reference the variable using the following syntax:

```
INSERT INTO my_table_ref (my_table_id, refd)
    VALUES (:my_insert_id, 'refVal');

```

In order for this to work with PostgreSQL the id field for the table needs to be backed by a sequence named `_id_seq`.

### **WIP** Normalization of SERIAL fields

[](#wip-normalization-of-serial-fields)

Most databases support a field type that is an auto incrementing integer most commonly used for primary keys, however they all seem to have a slightly different syntax. When writing your alter scripts you can write these statements for whichever database you are comfortable with and dbUp will handle it correctly for whichever database your script is being run against.

This feature is currently a WIP and only supports a limitted number of use cases (i.e the ones I've need personally). If you find a various that's not working create an issue, it should be fairly easy to add support.

Current support includes:

- MySQL `integer [NOT NULL] AUTO_INCREMENT` field can be executed against a PostgreSQL connection. Field can be specified as not null.
- That's it.

### **WIP** Normalization of ALTER TABLE

[](#wip-normalization-of-alter-table)

Some support for normalizing the various `ALTER TABLE` commands

- MySQL `ALTER TABLE  MODIFY [COLUMN]  ` and PgSQL `ALTER TABLE  ALTER COLUMN  [SET DATA] TYPE `statements are normalized.

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/483277?v=4)[Philip Graham](/maintainers/pgraham)[@pgraham](https://github.com/pgraham)

---

Top Contributors

[![pgraham](https://avatars.githubusercontent.com/u/483277?v=4)](https://github.com/pgraham "pgraham (68 commits)")

### Embed Badge

![Health badge](/badges/zeptech-dbup/health.svg)

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M117](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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