faimmedia/migration
最新稳定版本:0.3.1
Composer 安装命令:
composer require faimmedia/migration
包简介
FaimMedia Simple PHP Database Migration
README 文档
README
Simple PHP migration library to use with any available PHP PDO driver.
Install & usage
Add composer
Install this library using composer:
composer require faimmedia/migration
Run migrations (using CLI)
Use the ./vendor/bin/migrate command to run the migrations.
Example:
./vendor/bin/migrate \
--path=migration/path \
--dsn="pgsql:host=postgres;dbname=database" \
--username=postgres
To migrate to a specific version, you may also include the --version parameter. This will apply or undo only specific versions.
./vendor/bin/migrate \
--path=migration/path \
--dsn="pgsql:host=postgres;dbname=database" \
--username=postgres \
--version=0002
Run migrations (from PHP)
<?php use FaimMedia\Migration\Migration; use FaimMedia\Migration\Migration\Logger\Color; /** * Initialize */ $migration = new Migration([ 'dsn' => '', 'username' => 'username', 'password' => 'my-super-secret-password', ], new Color()); /** * Run all migrations */ $migration->run();
Or you can run a specific set of migrations:
Mmigrations that are already applied will be rolled back if there are -down file present for the specific version and name.
$migration->run('0003');
Development
Start up docker containers:
docker compose up -d
Run tests:
./bin/test
Run migration CLI:
docker compose exec -T test /app/bin/migrate --dsn=pgsql:host=postgres --username=migrate-test --path=/app/test/sql
统计信息
- 总下载量: 1.41k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-04-27