davedevelopment / phpmig

Simple migrations system for php
Other
569 stars 92 forks source link

generate an initial migration from an existing db #117

Closed andrezap closed 7 years ago

andrezap commented 7 years ago

I already have a db created and I would like to use phpmig now, but I need to generate the migrations with my current table structures. Is this possible?

AntonLee commented 7 years ago

It is possible. You can put pretty much any PHP code into migration. But if you want to store migrations log in DB you need to setup DB and connection to it first.

andrezap commented 7 years ago

sorry, I dont know if i was clear enough. but my case is: I have a DB, my structure already created, now I'll use phpmig and i dont know if there is a command that inspect my database and create an initial migration file with the current table structures as a starting point.

AntonLee commented 7 years ago

There is no such command, as far as I know. But you can just use a SQL dump for this.

davedevelopment commented 7 years ago

Yes, my preference would be to dump the existing DB to SQL and have the first migration load that sql dump.

If you require something more portable, you'll need another library from somewhere to reverse engineer the schema in to something else.

andrezap commented 7 years ago

ok guys, thank you, im gonna try it