All Projects → e282486518 → yii2-console-migration

e282486518 / yii2-console-migration

Licence: other
yii2命令行中使用migration备份和还原数据库

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to yii2-console-migration

Yii2 Migration
Yii 2 Migration Creator And Updater
Stars: ✭ 262 (+648.57%)
Mutual labels:  yii2, migration
illuminate
Yii2 to Laravel Migration Package
Stars: ✭ 71 (+102.86%)
Mutual labels:  yii2, migration
funboot
基于Yii2的Saas快速开发平台,内置多商户并内置商城、论坛、CMS等子系统。Yii2/Mysql/Mongodb/Redis/Elasticsearch/SnowFlake雪花算法ID生成 RBAC动态权限 数据权限 定时任务 日志/消息 代码生成Gii升级
Stars: ✭ 273 (+680%)
Mutual labels:  yii2
yii2-querybuilder
Extension for Yii2 Framework to work with jQuery QueryBuilder
Stars: ✭ 41 (+17.14%)
Mutual labels:  yii2
upscheme
Database migrations and schema updates made easy
Stars: ✭ 737 (+2005.71%)
Mutual labels:  migration
modoboa-imap-migration
An extension to ease the migration between 2 IMAP servers using offlineimap
Stars: ✭ 14 (-60%)
Mutual labels:  migration
luya-module-cms
The LUYA CMS module provides a full functional CMS for adding contents based on blocks.
Stars: ✭ 28 (-20%)
Mutual labels:  yii2
ar-search
Provides unified search model for Yii ActiveRecord
Stars: ✭ 31 (-11.43%)
Mutual labels:  yii2
django-wordpress-parser
Wordpress eXtended RSS Parser (in Python for Django)
Stars: ✭ 18 (-48.57%)
Mutual labels:  migration
MigrateGitlabToGogs
Migrate repositories from Gitlab to Gogs or Gitea
Stars: ✭ 49 (+40%)
Mutual labels:  migration
yii2-bankcard-info
银行卡卡号分析(Yii2扩展)
Stars: ✭ 15 (-57.14%)
Mutual labels:  yii2
yii2-flatpickr
Datetime picker widget for Yii2 framework
Stars: ✭ 17 (-51.43%)
Mutual labels:  yii2
yii2-pgsql
Improved PostgreSQL schemas for Yii2
Stars: ✭ 34 (-2.86%)
Mutual labels:  yii2
yii2-vue-admin
Yii2 Vue Admin Template
Stars: ✭ 22 (-37.14%)
Mutual labels:  yii2
behavior-trait
Allows handling events via inline declared methods, which can be added by traits
Stars: ✭ 18 (-48.57%)
Mutual labels:  yii2
yii2-rest-api
Yii 2 REST API Project Template
Stars: ✭ 36 (+2.86%)
Mutual labels:  yii2
yii2-cashier
Yii2 Cashier provides an interface to Stripe's subscription billing services.
Stars: ✭ 43 (+22.86%)
Mutual labels:  yii2
Migrate2Postgres
Easily migrate from other DBMSs to PostgreSQL
Stars: ✭ 47 (+34.29%)
Mutual labels:  migration
yii2-realtime-chat-example
Yii2 simple realtime chat with websocket.io
Stars: ✭ 17 (-51.43%)
Mutual labels:  yii2
yii2-switch-widget
Bootstrap Switch Widget for Yii2
Stars: ✭ 17 (-51.43%)
Mutual labels:  yii2

注意:如果你使用的是php7.2,那么yii必须使用v2.0.15.1以上,因为yii2核心类Object和php7.2的保留类Object冲突。

use yii\base\Object // PHP7.1以及之前版本
use yii\base\BaseObject // PHP7.2

yii2使用migration备份和还原数据库

yii2使用migration备份和还原数据库,最初只想做一个在命令行中备份的功能,后来将类重组了,增加了其他扩展使用方法。

安装 Installation

安装此扩展的首选方式是通过 composer.

运行

composer require e282486518/yii2-console-migration "@dev"

或者添加

"e282486518/yii2-console-migration": "*"

composer.json 文件的对应地方.

命令行中备份数据表:

console\config\main.php中添加 :

'controllerMap' => [
    'migrate' => [
        'class' => 'e282486518\migration\ConsoleController',
    ],
],

在命令行中使用方式:

php ./yii migrate/backup all #备份全部表
php ./yii migrate/backup table1,table2,table3... #备份多张表
php ./yii migrate/backup table1 #备份一张表

php ./yii migrate/up #恢复全部表

在后台中备份数据表:

在后台的控制器中,例如PublicController中加入下面的代码:

public function actions()
{
    return [
        'backup' => [
            'class' => 'e282486518\migration\WebAction',
            'returnFormat' => 'json',
            'migrationPath' => '@console/migrations'
        ]
    ];
}

在后台中发送一个ajax请求到/admin/public/backup?tables=yii2_ad,yii2_admin即可。

其他使用方法:

对于想做更多扩展的朋友,可以直接继承e282486518\migration\components\MigrateCreate

或者使用一下代码:

$migrate = Yii::createObject([
        'class' => 'e282486518\migration\components\MigrateCreate',
        'migrationPath' => $this->migrationPath
]);
$migrate->create($table);
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].