PHPackages                             djordje/li3\_migrations - 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. djordje/li3\_migrations

ActiveLithium-library[Database &amp; ORM](/categories/database)

djordje/li3\_migrations
=======================

Database migrations for Lithium PHP framework

2401[1 issues](https://github.com/djordje/li3_migrations/issues)PHP

Since Apr 30Pushed 8y ago2 watchersCompare

[ Source](https://github.com/djordje/li3_migrations)[ Packagist](https://packagist.org/packages/djordje/li3_migrations)[ RSS](/packages/djordje-li3-migrations/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Database migrations for Lithium framework [![Build Status](https://camo.githubusercontent.com/eb41930b4e16fb6740698739fe5838cc5a82d5bd1c16cfe4be7d9541177593f7/68747470733a2f2f7472617669732d63692e6f72672f646a6f72646a652f6c69335f6d6967726174696f6e732e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/djordje/li3_migrations)
===========================================================================================================================================================================================================================================================================================================================================

[](#database-migrations-for-lithium-framework-)

---

Dependencies
------------

[](#dependencies)

[li3\_fixtures](https://github.com/UnionOfRAD/li3_fixtures) - [Installation instructions](https://github.com/UnionOfRAD/li3_fixtures#readme)

[lithium](https://github.com/UnionOfRAD/lithium) from `master` branch (after v0.11) with integrated `li3_sqltools`

Usage
-----

[](#usage)

#### `create migration`

[](#create-migration)

Create new migration file with `li3 create migration` command:

```
li3 create migration Users
//app/resources/migration/20130506002905_Users.php

```

```
	namespace app\resources\migration;

	class Users extends \li3_migrations\models\Migration {

		protected $_fields = [];

		protected $_records = [];

		protected $_meta = [];

		protected $_source = 'users';

		public function up() {}

		public function down() {}

	}
```

Each field can have a type, length, if default or nullable

```
	protected $_fields = [
		'id' => ['type' => 'id'],
		'name' => ['type' => 'string', 'default' => 'foo', 'length' => 128, 'null' => false],
		'bar_id' => ['type' => 'integer']
	];

```

Meta can be used to set constraints, table engine, charset

```
	protected $_meta = [
		'constraints' => [
			[
				'type' => 'foreign_key',
				'column' => 'id',
				'toColumn' => 'id',
				'to' => 'other_table'
			]
		],
		'table' => ['charset' => 'utf8', 'engine' => 'InnoDB']
	];

```

Examples

Create new table up and down

```
	public function up() {
		return $this->create()
	}

	public function down() {
		return $this->drop();
	}

```

Create new table and add records

```
	protected $_records = array(
		['name' => 'foo', 'type' => 1],
		['name' => 'bar', 'type' => 1]
	);

	public function up() {
		if (!$this->create())
			return false;

		return $this->save();
	}

	public function down() {
		return $this->drop();
	}

```

You can provide arguments to command:

- `source` - custom table name (this is value of `source` property): `--source=site_users`
- `library` - specify library to use: `--library=li3_usermanager`

#### `migrate`

[](#migrate)

Run migrations with `li3 migrate` command:

Available `li3 migrate` actions:

- `up` - accept timestamp param: `li3 migrate up` or `li3 migrate up 20130505` or `li3 migrate up 20130505102033`
- `down` - accept timestamp param: `li3 migrate down 1` or `li3 migrate down 20130505` or `li3 migrate down 20130505102033`
- `show-available` - generate table with all available migrations in current library
- `show-state` - show timestamp of latest applied migration

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 67.9% 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/1223357?v=4)[Djordje Kovacevic](/maintainers/djordje)[@djordje](https://github.com/djordje)

---

Top Contributors

[![djordje](https://avatars.githubusercontent.com/u/1223357?v=4)](https://github.com/djordje "djordje (19 commits)")[![jesusfreak3](https://avatars.githubusercontent.com/u/863030?v=4)](https://github.com/jesusfreak3 "jesusfreak3 (9 commits)")

### Embed Badge

![Health badge](/badges/djordje-li3-migrations/health.svg)

```
[![Health](https://phpackages.com/badges/djordje-li3-migrations/health.svg)](https://phpackages.com/packages/djordje-li3-migrations)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k116.5M113](/packages/jdorn-sql-formatter)[propel/propel1

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

8351.6M87](/packages/propel-propel1)[pgvector/pgvector

pgvector support for PHP

198628.3k10](/packages/pgvector-pgvector)

PHPackages © 2026

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