定制 lav45/yii2-db-migrate 二次开发

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

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

lav45/yii2-db-migrate

Composer 安装命令:

composer require lav45/yii2-db-migrate

包简介

This extension allows you to easily create large migrations associated with many foreign keys.

README 文档

README

Это расширение поможет вам избежать конфликтов в вашей SQL db при создании foreign key.

Установка расширения

~$ composer require --prefer-dist lav45/yii2-db-migrate

Подключение

use lav45\db\MainMigration;

class m000000_000000_init extends MainMigration
{
    // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
    public $defaultTableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';

    public function table_news()
    {
        $this->createTable('news', [
            'id' => $this->primaryKey(),
            'author_id' => $this->integer()->notNull(),
            // ...
        ]);
        
        $this->addForeignKey('news', 'author_id', 'user', 'id', 'SET NULL');
    }
    
    public function table_news_tag()
    {
        $this->createTable('news_tag', [
            'news_id' => $this->integer()->notNull(),
            'tag_id' => $this->integer()->notNull(),
        ]);

        $this->addPrimaryKey('news_tag', ['news_id', 'tag_id']);

        $this->addForeignKey('news_tag', 'news_id', 'news', 'id');
        $this->addForeignKey('news_tag', 'tag_id', 'tag', 'id');
    }

    public function table_tag()
    {
        $this->createTable('tag', [
            'id' => $this->primaryKey(),
            // ...
        ]);
    }

    public function table_user()
    {
        $this->createTable('user', [
            'id' => $this->primaryKey(),
            // ...
        ]);
    }
}
~$ php yii migrate/up
Yii Migration Tool (based on Yii v2.0.7-dev)

Creating migration history table "migration"...Done.
Total 1 new migrations to be applied:
        m000000_000000_init

*** applying m000000_000000_init
    > create table user ... done (time: 0.072s)
    > create table news ... done (time: 0.064s)
    > add foreign key news_author_id_fkey: news (author_id) references user (id) ... done (time: 0.001s)
    > create table news_tag ... done (time: 0.001s)
    > add primary key news_tag_pk on news_tag (news_id,tag_id) ... done (time: 0.086s)
    > add foreign key news_tag_news_id_fkey: news_tag (news_id) references news (id) ... done (time: 0.001s)
    > create table tag ... done (time: 0.066s)
    > add foreign key news_tag_tag_id_fkey: news_tag (tag_id) references tag (id) ... done (time: 0.001s)
*** applied m000000_000000_init (time: 0.292s)


1 migrations were applied.

Migrated up successfully.

lav45/yii2-db-migrate 适用场景与选型建议

lav45/yii2-db-migrate 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17.67k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 05 月 21 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「db」 「extension」 「migrate」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 lav45/yii2-db-migrate 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 lav45/yii2-db-migrate 我们能提供哪些服务?
定制开发 / 二次开发

基于 lav45/yii2-db-migrate 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2015-05-21