jfranclin/migrations

此包的最新版本(dev-master)没有提供许可信息。

dev-master 2016-02-17 16:48 UTC

This package is not auto-updated.

Last update: 2024-09-14 18:52:59 UTC


README

通过Doctrine Migrations管理SQL模块。

先决条件

PHP 5.5.x | 7.x

安装

composer require jfranclin/migrations

  • 将 migrations-db.php.conf (不要删除) 复制到一个新的文件 migrations-db.php。使用项目信息配置此文件。
  • 如果需要,在项目根目录下创建一个 "migrations" 文件夹。
  • 将 migrations.yml.conf (不要删除) 复制到一个新的文件 migrations.yml。配置此文件。
  • 编辑 migrations.yml 文件,将最后一行替换为:migrations_directory: ../../../migrations

注意,需要 Pdo MySQL 驱动程序(在Windows上安装Wamp,否则在Linux上:sudo apt-get install php5-mysql)。

在虚拟机中

  • 在MySQL中

GRANT ALL PRIVILEGES ON datbaseName.* TO 'user'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;

FLUSH PRIVILEGES;

  • 防火墙

sudo iptables -I INPUT -p tcp --dport 3306 -j ACCEPT -m comment --comment "Allow_remote"

sudo iptables-save > /etc/iptables_rules

sudo nano /etc/rc.local 并在 exit 前添加:/sbin/iptables-restore < /etc/iptables_rules

如何使用

  • 定位到 vendor/jfranclin/migrations

  • 状态:php migration status

  • 创建迁移:php migration generate

  • 运行迁移:' php migration migrate

  • 取消迁移:php migration migrate NUMERO_MIGRATION

  • 测试迁移而不执行:php migration --dry-run

  • 生成SQL文件:php migration --write-sql