Import database

I have just started using yii2.

I am now about to start re-building and old project writing in just core php (about 10 years old). The DB structure on the role is great (any amendments can be done with migrate), how can I create migrations for all databases (about 250 tables).

I believe I need to migrate the tables in, as without this i cannot use crud tools

Regards

Richard

You don’t need to create migrations in this case. Just import the database and use the crud tools to generate what you need. The migrations use after you set up the dev database to easy port the changes made on the dev db to a production db.

Of course the best is if your legacy database is innodb, then you will use the whole power of AR.

Cheers,

Andrzej

Great, thank you.

I have only used innodb for years now as I think its much better.

Ok, so if i understand correctly I follow this flow.

A: Create version 2 of the app

  1. Import my remote DB

  2. using migrations make changes to the db where required

B: then when I am ready to go to production

  1. Upload files to remote host

  2. init to production mode on remote host

  3. run migration commands

Then as i develop and maintain the app over the following years just repeat step B.

I would set up the dev version of the database and the production version from the same sql source file. I treat it as "a point zero" where you start the developing process from. After that, if some changes are being made on the dev version I would reflect it with migrations and fire the migrations on the production.

And the last sentence is repeatable: Reflect all changes on the dev db with migrations and fire the migrations on the production and so on.

Sorry for my stupidity

  1. I have already a production db. I have now downloaded that and an building the app in development at the moment (as of 1 hr ago).

Just so I understand. Locally i work on the development DB and make all the changes required. My client is using the old app with the production db now. Then when i am ready and it tested locally I plan to do the following.

  1. upload app on to a dev.xx.com testing domain for client

  2. init that app to production

  3. apply db changes (only up not down as do not want to destroy production v1 app)

  4. when client approves move to live root and apply down changes to db.

repeat steps 1-4 as a rolling process.

Thank you for all your help.