Welcome Guest, Not a member yet? Register   Sign In
Generate migration file from existing database?
#1

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

Bridging the gap between Technical and Creative

VASCOsoft Web Studio   |   AllMyLinks

Reply
#2

@PwrSrg,

What is the database type (MySQL, Oracle, Postgres, etc...)?
Reply
#3

(11-25-2020, 07:20 AM)php_rocs Wrote: @PwrSrg,

What is the database type (MySQL, Oracle, Postgres, etc...)?

MariaDB (MySQL)

Bridging the gap between Technical and Creative

VASCOsoft Web Studio   |   AllMyLinks

Reply
#4

(This post was last modified: 11-25-2020, 03:38 PM by InsiteFX.)

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 )
Reply
#5

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! ***/
Reply
#6

This would be a great tool. I already have 3 projects where I have to manually write migrations from existing databases
Reply
#7

See https://forum.codeigniter.com/thread-634...#pid324798

You can write code to run the export file in a migration file.
Reply
#8

Thanks. I'll try this
Reply




Theme © iAndrew 2016 - Forum software by © MyBB