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.
将本要点的内容复制到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.
将 up() 和 down() 方法从 initial_migration.php 复制并粘贴到 中创建的文件中>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中根据W3C规范Unicode 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何替换eregi() 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
