Generate migration file from existing database? |
Hello,
I watched a video on how to create database migrations from scratch, which is very handy. But the thought of creating many large tables from scratch at the beginning of a project sounds extremely tedious and a huge waste of time, when I can fly through them in Navicat. Or in most cases am starting with pre-existing tables and data from previous projects. What is the command to generate the initial migration file from an existing database already FULL of tables and data? Thanks! -Sergio (11-25-2020, 07:20 AM)php_rocs Wrote: @PwrSrg, MariaDB (MySQL)
There is no migration command to create a migration from an existing database.
You would need to export it and manually convert it over to a migration file. The command to create a blank migration file is: php spark migrate:create [filename] I have looked into this there is a utility for the Laravel framework to do just that To much trouble to write something like that just for a utility. You can find it here: Laravel Migrations Generator What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Migrations and Seeders are great for small projects, but if you have a lot of existing tables or a lot of data, I think it's better to export the database and use SQL scripts.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
This would be a great tool. I already have 3 projects where I have to manually write migrations from existing databases
See https://forum.codeigniter.com/thread-634...#pid324798
You can write code to run the export file in a migration file. (04-23-2022, 06:25 AM)kenjis Wrote: See https://forum.codeigniter.com/thread-634...#pid324798 allow me to say it is unexpected that in CI4 there is no such utility for at least the popular MySQL DB I mean the automatic generation of migration for existing tables of an existing DB Obviously this is not needed for the development phase, you can import whatever in natively SQL or with the aid of phpMyAdmin or others DB tools The need is when it is time to deliver the app Sure, it is a specific utility but it is true as well that there are various helpers delivered in/with the Codeigniter suite. I would put this in a TODO list ( not urgent.... e.g. when spare time is available. I know days have only 24h , what a shame ) together with a 4th guide in the Shield documentation (I mean one which shows the correct implementation of Shield in a common scenario where to limit the access to admins only for some of the controllers). R. |
Welcome Guest, Not a member yet? Register Sign In |