I designed a database in MYSQL. Now I want to connect that with my Laravel application. But after researching, I understand that I need to migrate the database into Laravel by creating migration tables. But doing the same thing that I did in MySQL is tedious. I think there is another way to do the stuff. After searching I got this article from stackoverflow, but this is related to yii framework. I think someone knows here the solution of my problem.
-
It's not necessary. If you have designed DB and related models, you can import it through SSH or PhpMyAdmin. – EHF Shahab Aug 21 '22 at 11:24
-
@EHFShahab, Could you please mention some related links or describe here how I can do that? – Siddikur Aug 21 '22 at 11:29
-
Your laravel app has been installed yes? – EHF Shahab Aug 21 '22 at 11:34
3 Answers
I don't see a problem here, you can just connect Laravel to your DB (by editing your .env file) without any problems, migration files are just an easier way to design and implement your tables (also altering your tables' scheme on production is a very useful usage for migrations), but with that being done then no further actions are required, and you are good to go!

- 260
- 2
- 11
it's pretty obvious, you can update the database setting in the .env file and use DB::table('your_table_name') and get whatever query you want.

- 7
- 3
The upside of using migrations is that the exact same database can be created on different systems (ex: co-workers or acceptance/production servers).
Laravel migrations have an up
and a down
function so you can rollback to a specific version if something went wrong, very usefull when publishing your code.
That being said, co-workers could also review the database changes and for example hint at using more indexes and foreign keys.
As the other comments said, it's not a requirement you use migrations but it has considerable advantages versus creating and updating the database manually.

- 1,239
- 7
- 12