承接 nkovacs/yii2-table-builder 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

nkovacs/yii2-table-builder

Composer 安装命令:

composer require nkovacs/yii2-table-builder

包简介

Table builder migration helper extension for Yii 2

README 文档

README

Table builder migration helper extension for Yii 2

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist nkovacs/yii2-table-builder "*"

or add

"nkovacs/yii2-table-builder": "*"

to the require section of your composer.json file.

Usage

In order to use this extension, your migrations must extend from \nkovacs\tablebuilder\Migration. Once the extension is installed, it will override the migrate command's templateFile property during application bootstrap process, allowing you to use the extension's Migration class in newly created migrations, provided you did not override templateFile yourself.

An example migration:

<?php

use yii\db\Schema;

class m140701_113939_test extends \nkovacs\tablebuilder\Migration
{
    public $tables;

    public function init()
    {
        parent::init();
        $this->tables = [
            '{{%table_a}}' => [
                'id'   => Schema::TYPE_PK,
                'name' => Schema::TYPE_STRING,
            ],
            '{{%table_b}}' => [
                'id'   => Schema::TYPE_PK,
                'name' => Schema::TYPE_STRING,
            ],
            '{{%table_c}}' => [
                'id'      => Schema::TYPE_PK,
                'user_id' => [Schema::TYPE_INTEGER, '{{%user}}', 'id', 'delete' => 'SET NULL', 'update' => 'CASCADE'],
                'a_id'    => [Schema::TYPE_INTEGER, '{{%table_a}}', 'id', 'delete' => 'RESTRICT', 'update' => 'CASCADE'],
                'b_id'    => [Schema::TYPE_INTEGER, '{{%table_b}}', 'id', 'delete' => 'RESTRICT', 'update' => 'CASCADE'],
                'name'    => Schema::TYPE_STRING,
            ],
            '{{%table_d}}' => [
                'a_id'    => [Schema::TYPE_INTEGER, '{{%table_a}}', 'id', 'delete' => 'RESTRICT', 'update' => 'CASCADE'],
                'b_id'    => [Schema::TYPE_INTEGER, '{{%table_b}}', 'id', 'delete' => 'RESTRICT', 'update' => 'CASCADE'],
                ['primary' => ['a_id', 'b_id']],
            ]
        ];
    }

    public function up()
    {
        $this->build($this->tables);
    }

    public function down()
    {
        $this->teardown($this->tables);
    }
}

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2014-07-01

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固