laravel 如何从laravel中的现有数据库创建迁移
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24200981/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to create migration from existing database in laravel
提问by Hitesh Modha
I am new to laravel
. i know command to create database from laravel
migration.
我是新手laravel
。我知道从laravel
迁移创建数据库的命令。
I have already created database in mysql
. so how can i convert migration from that database.
我已经在mysql
. 那么如何从该数据库转换迁移。
采纳答案by nielsiano
You could use Jeffrey Way's generator tool for Laravel 4, and do them by hand. It is a veryuseful tool. https://github.com/JeffreyWay/Laravel-4-Generators(if you are using Laravel 5, use this package instead: https://github.com/laracasts/Laravel-5-Generators-Extended)
你可以在 Laravel 4 中使用 Jeffrey Way 的生成器工具,然后手工完成。这是一个非常有用的工具。https://github.com/JeffreyWay/Laravel-4-Generators(如果您使用的是 Laravel 5,请改用此包:https: //github.com/laracasts/Laravel-5-Generators-Extended)
Or you could try out one of the following packages, they should convert your existing schema to Laravel migrations. I have not tried them, but have a look:
或者您可以尝试以下包之一,它们应该将您现有的架构转换为 Laravel 迁移。我还没有尝试过,但看看:
Also, read the following answer in another question, might be useful to you or others: Reverse engineering or Auto-Generations of Entities in Laravel?
另外,请阅读另一个问题中的以下答案,可能对您或其他人有用:Laravel 中的逆向工程或实体自动生成?
回答by Joel Lim
I quick wrote this python script to make migration files out of an existing database.
我快速编写了这个 python 脚本来从现有数据库中生成迁移文件。
https://github.com/aljorhythm/sql-to-laravel-migrations
https://github.com/aljorhythm/sql-to-laravel-migrations
After set up, just do
设置后,只需执行
python retrieve-and-convert.py
回答by Akash khan
Simple solution, to use online Laravel migration generator for your existing SQL table schema without installing any package. Just enter your SQL schema and get Laravel migration file. Try: https://laravelarticle.com/laravel-migration-generator-online
简单的解决方案,在不安装任何包的情况下,为您现有的 SQL 表模式使用在线 Laravel 迁移生成器。只需输入您的 SQL 模式并获取 Laravel 迁移文件。试试:https: //laravelarticle.com/laravel-migration-generator-online