elcheco/nette-phinx-bridge

扩展,将Phinx命令集成到Nette框架的contributte/console中,使用框架的配置文件。

v0.3.2 2020-12-19 01:01 UTC

This package is auto-updated.

Last update: 2024-09-19 09:11:04 UTC


README

Downloads this Month License

扩展,将Phinx命令集成到Nette框架的contributte/console中,使用框架的配置文件。

注意:受 (https://github.com/banyacz/phinx-nette-bridge) 启发,但更新到了Nette DI、Phinx和Contribute Console的最新库版本,因为作者没有沟通。

需求

安装

  1. composer require elcheco/nette-phinx-bridge
  2. 注册DI扩展
extensions:
    phinx: ElCheco\Phinx\Extension

配置

phinx:
    paths: # directories must exist
        migrations: "./db/migrations"
        seeds: "./db/seeds"
    environments:
        default_migration_table: migrations
        development:
            adapter: mysql
            host: 'localhost'
            name: db_name
            user: root
            pass: '123456'
            port: 3306
            charset: utf8
    version_order: creation

使用

{CONSOLE} phinx:breakpoint
{CONSOLE} phinx:create
{CONSOLE} phinx:migrate
{CONSOLE} phinx:rollback
{CONSOLE} phinx:seed:create
{CONSOLE} phinx:seed:run
{CONSOLE} phinx:status  

示例

在我的情况下,我的控制台在路径 bin\console

bin\console phinx:create AddNewTable

打印输出

> using migration paths 
>  - /Users/elcheco/www/project_dir/db/migrations
> using migration base class Phinx\Migration\AbstractMigration
> using default template
> created db/migrations/20180928135219_add_new_table.php

或者对于种子

bin\console phinx:seed-create FillNewTable

它将打印

> using migration paths 
>  - /Users/elcheco/www/project_dir/db/migrations
> using seed paths 
>  - /Users/elcheco/www/project_dir/db/seeds
> using seed base class Phinx\Seed\AbstractSeed
> created ./db/seeds/FillNewTable.php