PHPackages                             sidvind/php-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. sidvind/php-migrations

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

sidvind/php-migrations
======================

Database migration scripts for PHP

v2.0.1(7y ago)04.2kMITPHP

Since Feb 15Pushed 7y ago1 watchersCompare

[ Source](https://github.com/ext/php_migrations)[ Packagist](https://packagist.org/packages/sidvind/php-migrations)[ RSS](/packages/sidvind-php-migrations/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (3)Used By (0)

Introduction
============

[](#introduction)

This is a php-script that helps you handling versions of your database in a format that works well with code versioning.

This is a fork of [torandi/php\_migrations](torandi/php_migrations) with **breaking** changes.

Differences
-----------

[](#differences)

- `update_database` will exit with error codes on any error.
- `--check` is renamed `--dry-run`.
- Misc additional CLI options such as `--config`.
- Uses `getopt-php` instead of custom argument parsing.

Configuration and setup
-----------------------

[](#configuration-and-setup)

1. `composer require sidvind/php-migrations`
2. Create a directory in your project named `migrations` (or whatever)
3. Symlink `update_database.php` and `create_migration.php` into the directory.
4. Copy `config-example.php` to `config.php` and edit it to fit your project (see `config-example.php` for more info)

Usage
-----

[](#usage)

Use `migrations/create_migration.php migration_name` to create a new migration.

This creates a empty migration with a name like `20110821231945_migration_name.sql`. The file name (including the date) is the version name, and must be unique.

You may also specify a second argument to create\_migration to select file format (sql or php):

- SQL: SQL to be run for the migration (multiple lines separated by ;)
- PHP: PHP code to be executed, the environment you loaded in `config.php` is available, remember `
