drago-ex/migration 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

drago-ex/migration

最新稳定版本:v1.0.0

Composer 安装命令:

composer require drago-ex/migration

包简介

A simple CLI tool for running SQL migrations.

README 文档

README

A simple CLI tool for running SQL migrations.

Drago Migration is a lightweight CLI tool built on Nette, Dibi and Symfony Console. It allows you to run SQL migrations from files or directories with checksum validation, transactional execution and database-level locking.

License: MIT PHP version Coding Style

Requirements

  • PHP >= 8.3
  • Nette Framework
  • Symfony Console
  • dibi
  • Composer

Install

composer require drago-ex/migration

Register Migration Extension in Nette

extensions:
    migration: Drago\Migration\DI\MigrationExtension(%consoleMode%)
    console: Contributte\Console\DI\ConsoleExtension(%consoleMode%)

# symfony console
console:
	name: Symfony Console
	version: '1.0'

Make sure the %consoleMode% parameter is available (usually already present in Nette CLI setups).

Database Setup

Create the migrations table in your database:

CREATE TABLE IF NOT EXISTS migrations (
    id INT AUTO_INCREMENT PRIMARY KEY,
    package VARCHAR(255) NOT NULL,
    migration_file VARCHAR(255) NOT NULL,
    checksum CHAR(40) NOT NULL,
    executed_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
    CONSTRAINT uq_migrations_package_file
        UNIQUE (package, migration_file)
)
ENGINE = InnoDB
DEFAULT CHARSET = utf8mb4
COLLATE = utf8mb4_unicode_ci;

Usage

Run migrations using the Composer-installed binary:

php vendor/bin/migration db:migrate <path>

Path to a single SQL file or a directory containing multiple .sql files.

Examples

# Run all migrations in a folder
php vendor/bin/migration db:migrate migrations

# Run a single migration file
php vendor/bin/migration db:migrate migrations/001_example.sql

Features

  • Checksum validation – detects modified migrations
  • Transactional execution – safe rollback on failure
  • Database locking – prevents concurrent runs
  • Package-aware migrations – supports vendor-based migrations
  • Symfony Console integration – clean CLI output

Notes

  • This package is designed for Nette Framework projects.
  • The provided CLI binary expects a Nette project structure with app/Bootstrap.php.
  • For non-Nette projects, a custom bootstrap script is required.

统计信息

  • 总下载量: 13
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-29