承接 dastanaron/yii2-migrate-updater 相关项目开发

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

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

dastanaron/yii2-migrate-updater

Composer 安装命令:

composer require dastanaron/yii2-migrate-updater

包简介

The extension allows you to save data when performing a ./yii migrate/redo

README 文档

README

На русском ТУТ

This extension allows you not to lose data when executing ./yii migrate/redo

We all know that Yii2 does not have a table update system. There is redo, which removes the table and recreates it according to the specified rules. This is good, but sometimes, You need to update the system, including the tables and still not lose data.

This solution allows this, but provided that the new fields appearing in the table will be with the resolution null. In addition, the new table should not delete the old columns.

Then maybe we'll fix it, but in the initial stages it will be like this.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist dastanaron/yii2-migrate-updater "*"

or add

"dastanaron/yii2-migrate-updater": "*"

to the require section of your composer.json file and run

php composer.phar update

Usage

The use is fairly simple, you must install this solution and connect the class in your migration class.

To save migrations, you need to connect the migration extension class, and use it, to create their own migrations. In addition, you must declare a public variable with the table name public $tableName

<?php

use dastanaron\yiimigrate\updater\ExtMigration;

class m171226_130601_youmigrationclass extends ExtMigration {
    
    public $tableName = 'youmigrationtable';
    
    //body class
    
}

By default, the class uses a flag that allows or denies the storage of data, it is specified in the parent class as public $saveData = true; if you do not need to try to save data, reassign this property in its class to disable this functionality

<?php

use dastanaron\yiimigrate\updater\ExtMigration;

class m171226_130601_youmigrationclass extends ExtMigration {
    
    public $tableName = 'youmigrationtable';
    
    public $saveData = false; //disable data saving
    
    //body class
    
}

This functionality is implemented by the auxiliary class TableData. Below, you can see its methods and properties that you can use outside of migration extensions and for diagnostics.

Methods of the TableData class

  • ** getData () ** - makes a request to the database to receive data, using yii\db\Query
  • ** Dump ($type = 'create') ** - creates or reads the dump of the table, respectively the passed parameters create or read
  • ** getInsertString () ** - gets the assembled insert sql string. For diagnosis

Attention

After reading, the dump is deleted

If you want to see an array of collected or other data, then you can use the public properties of the class TableData

Public Properties

  • ** $tablename ** - the name of the table, is obtained in the constructor
  • ** $selecteddata ** - after the request, will contain an array of data.
  • ** $sqlstring ** - the query string is obtained after its assembly

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固