Yii Migrations interface


Often it’s the case when we don’t have access to the shell on the target server.

Is there any extension that you can manage the migrations with?

Gii like or sth (I think that this should be part of gii anyway).


webshell extension

Nice, but still not the thing I asked for :)

You can run any yiic command - including migration commands - from webshell, and it doesn’t require shell access, so it meets your specified requirements :)

No. I asked for an extension with which you can manage VISUALLY the migrations, not by entering shell commands :slight_smile:

There is no such extension currently.

I was about to start the development of some Gii code generators to handle migrations and tought “Let me see in the forums if someone else already did it”. Seems that I’ll have to do it :)

So, I’ll take this opportunity to ask you: what features would you like in such generators. Off the top of my mind I have the following ideas:

  • Generate migrations for existing tables

  • GUI to create migrations (I’m thinking in something like phpMyAdmin or adminer, but much more simple, where you can create and alter tables)

  • An interface to run the migrations from Gii

Any other ideas?

I wouldn’t use a tool like that - fail to see the point.

I make heavy use of migrations, but they are part of my applications code base, like models, controllers, views, components, widgets…

For hosts that don’t have shell access, I just run yiic migrate in a popen php command.

If you want to make it easy for yourself and others, you could probably write an export extension for something like MySQL workbench.

I really like that my migrations are just regular php code and put under source control.

But each to his own. :)

How would you handle versioning?

Sorry @jacmoe, but you really didnt saw the point :)

I’m talking about Gii Code Generators, so all that we’ll have in the end is php code. My idea with the GUI is just to make things easier, sometimes I think that “point and click” is better than type a lot of statements to create tables, etc. Specially if you have a lot os tables to create.

So you’ll still have all your files, just like the yiic migrate command, and still can use your source control system.

Actually you all kinda missed my point :)

My idea was as simple as having "migrations" menu in gii and a possibility to:

  • see if my db is up2date with migrations

  • run waiting migrations

  • revert migration to any previous one

  • see the migration content

A good idea, but since Gii should only be run on a development server, we still have a problem. :)

I misunderstood you as I thought you meant a visual database construction set. :)

Actually, such an interface is fairly easy to do, I do something like this in my installer:

            	$cmd = dirname(__FILE__) . "/../../../protected/yiic migrate --interactive=0";

            	// Run the command twice - second time around it should

            	// output that our system is up-to-date.

            	$output = stream_get_contents(popen($cmd, 'r'));

            	$output = stream_get_contents(popen($cmd, 'r'));

            	if (preg_match("/Your system is up-to-date/i", $output)) {

                	$message .= '<font color="green">Success:</font> Migration successfully applied.';

            	} else {

                	// TODO: handle this.

                	$message .= '<font color="red">Error:</font>An error occurred - here be dragons..';


Crude, yes. But it works.

But it shouldn’t be in Gii as that tool is only for development - it’s not safe in a production environment.