Generating migration from existing database in Yii or Laravel(从 Yii 或 Laravel 中的现有数据库生成迁移)
问题描述
我正在处理一个具有相当复杂的数据库(150 多个表)的项目.为了能够维护更改,我决定添加迁移,最好使用 Yii 或 Laravel.
I'm working on a project that has a fairly complex database (150+ tables). In order to be able to maintain changes, I've decided to add migrations, preferably using Yii or Laravel.
有人知道,是否可以从现有数据库生成初始迁移?
Does anybody know, if it is possible to generate a initial migration from an existing database?
手工创建会:
- 永远和
- 非常容易出错.
如果没有办法,有没有人知道一个好的基于 PHP 的框架,支持这样的功能?
If there is no way, does anybody know a good PHP-based framework, that supports such functionality?
推荐答案
在 Yii 中完成此操作的说明:
Instructions for accomplishing this in Yii:
将您的数据库连接设置添加到
protected/config/console.php
.
运行 yiic migrate create initial
为迁移创建存根代码.
Run yiic migrate create initial
to create the stub code for the migration.
将 this gist 的内容复制到 protected/commands/InitialDbMigrationCommand.php
.
Copy contents of this gist to protected/commands/InitialDbMigrationCommand.php
.
运行 yiic initialdbmigration 'name_of_your_database' >initial_migration.php
生成用于初始数据库迁移的 up()
和 down()
方法.
Run yiic initialdbmigration 'name_of_your_database' > initial_migration.php
to generate up()
and down()
methods for initial database migration.
将 initial_migration.php
中的 up()
和 down()
方法复制并粘贴到 中创建的文件中>protected/migrations
步骤 2 中的文件夹.
Copy and paste up()
and down()
methods from initial_migration.php
to the file created in the protected/migrations
folder in step 2.
这篇关于从 Yii 或 Laravel 中的现有数据库生成迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:从 Yii 或 Laravel 中的现有数据库生成迁移


基础教程推荐
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何替换eregi() 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01