定制 smartteam/migrations-bundle 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

smartteam/migrations-bundle

最新稳定版本:v2.2.0

Composer 安装命令:

composer require smartteam/migrations-bundle

包简介

Mantainance project of old ZenstruckMigrationsBundle

关键字:

README 文档

README

Mantainance project of old ZenstruckMigrationsBundle that enabled container aware migrations.

NOTE: For use with Symfony 2.0 use the 1.x branch

Installation

  1. Add to composer.json (see http://getcomposer.org/)

    "require" :  {
        "smartteam/migrations-bundle": "*",
    }
  2. Register the bundle

    <?php
    // app/AppKernel.php
    
    public function registerBundles()
    {
        $bundles = array(
            // ...
            new SmartTeam\Bundle\MigrationsBundle\SmartTeamMigrationsBundle(),
        );
        // ...
    )

Usage

  • To make use of container aware data migrations your migrations must extend SmartTeam\Bundle\MigrationsBundle\Migrations\AbstractMigration. (note: Migrations that extend Doctrine\DBAL\Migrations\AbstractMigration will still run normally)
  • Implement the dataUp() method and add your custom migration logic. (note: The up() method will be run before dataUp)
  • Implement the dataDown() method and add your custom migration logic. (note: The down() method will be run before dataDown)
  • Optionally implement the getDataDescription method and return a description of the migration.
  • Migrate using the smartteam:migrations:migrate command. (note: make sure you run migrations with this command and not doctrine:migrations:migrate

Migration Template

<?php

namespace Application\Migrations;

use SmartTeam\Bundle\MigrationsBundle\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Auto-generated Migration: Please modify to your need!
 */
class Version20120419113825 extends AbstractMigration
{
    public function up(Schema $schema)
    {
        // this up() migration is autogenerated, please modify it to your needs
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");

    }

    public function down(Schema $schema)
    {
        // this down() migration is autogenerated, please modify it to your needs
        $this->abortIf($this->connection->getDatabasePlatform()->getName() != "mysql");

    }
    
    public function dataUp(ContainerInterface $container)
    {
        // container aware logic
    }
    
    public function dataDown(ContainerInterface $container)
    {
        // container aware logic
    }

    /**
     * OPTIONAL
     */
    public function getDataDescription()
    {
        return parent::getDataDescription();
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-17