asko / migrator
A simple database migration library.
Installs: 148
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/asko/migrator
Requires
- php: >=8.2
Requires (Dev)
- phpstan/phpstan: ^1.11
- phpunit/phpunit: ^11
README
A simple, extendable database migration tool with out of box support for MySQL.
Installation
composer require asko/migrator
Usage
Your migration files should be placed in a directory. Each migration file is just a regular SQL file with a {up|down}.sql
extension. The migrations are run in file name order, so you should prefix the files numerically or with a timestamp, e.g 001_create_users_table.up.sql
.
use Asko\Migrator\Migrator; use Asko\Migrator\Drivers\MysqlDriver; $migrator = new Migrator('migrations_path', new MysqlDriver(...)); // Run migrations $migrator->migrate(); // Revert last migration $migrator->revert();