Yii Framework Forum: [extension] Yii DB Migrations - very early alpha release - Yii Framework Forum

Jump to content

  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

[extension] Yii DB Migrations - very early alpha release Rate Topic: -----

#1 User is offline   pclaerhout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 08-December 08

Posted 15 June 2009 - 02:42 AM

Hi all,

I've started working on an extension that can do database migrations for a Yii project. It's kind of inspired by what is possible in Ruby On Rails.

Currently, the basics are working for SQLite and MySQL. There is still a lot of work that needs to be done to make this a full working tool though.

You can have a look at what I've come up with so far on:
http://github.com/pi...i-dbmigrations/

Regards,


pieter
1

#2 User is offline   wei 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 147
  • Joined: 04-October 08

Posted 15 June 2009 - 06:42 PM

Hi Pieter,

That is an awesome piece of work! Documentation is top notch too.

++karma!

Cheers, Wei.
0

#3 User is offline   miles 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 89
  • Joined: 16-January 09
  • Location:Beijing

Posted 15 June 2009 - 08:44 PM

great
0

#4 User is offline   miles 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 89
  • Joined: 16-January 09
  • Location:Beijing

Posted 15 June 2009 - 08:57 PM

I hope that we can specify a different CDbConnection
0

#5 User is offline   pclaerhout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 08-December 08

Posted 16 June 2009 - 01:41 AM

You actually can specify a different connection in some way. Since the migrate command is part of the yiic tool, it looks at the settings defined in the "protected/config/console.php" configuration file while the webapp normally looks in the "protected/config/main.php" configuration file.

This way, you can have a db connectionstring for migrate that has a lot more rights than what the one you are using in the web application itself has.

regards,


pieter
0

#6 User is offline   Q-efx 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 12-April 09

Posted 16 June 2009 - 03:54 AM

WoW, nice piece of code :)

Will be there a "reverse" migration of existing tables?
0

#7 User is offline   pclaerhout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 08-December 08

Posted 16 June 2009 - 03:59 AM

Yes, currently, you can only migrate in the "up" direction, but the goal is that you can migrate in the "down" direction as well.

Eventually, I would like to come up with the following possibilities in the migrate command:

  • yiic migrate: applies all possible migrations
  • yiic migrate 20091116111958: migrate to that specific version
  • yiic migrate down: undo the last migration


That way, you can go any direction.

Regards,


pieter
0

#8 User is offline   miles 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 89
  • Joined: 16-January 09
  • Location:Beijing

Posted 16 June 2009 - 04:38 AM

Quote

You actually can specify a different connection in some way. Since the migrate command is part of the yiic tool, it looks at the settings defined in the "protected/config/console.php" configuration file while the webapp normally looks in the "protected/config/main.php" configuration file.



This way, you can have a db connectionstring for migrate that has a lot more rights than what the one you are using in the web application itself has.



regards,





pieter


thanks pieter
0

#9 User is offline   Q-efx 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 62
  • Joined: 12-April 09

Posted 16 June 2009 - 02:29 PM

And whats about creation of migrations with existing tables? :)
0

#10 User is offline   pclaerhout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 08-December 08

Posted 17 June 2009 - 01:38 AM

There are functions provided to add/edit things in existing tables.

I currently have no plans to automatically create migrations from an existing database though.

pieter
0

#11 User is offline   pclaerhout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 08-December 08

Posted 17 June 2009 - 08:15 AM

I've just made version 1.0a1 available of the Yii DB Migrations extension.

The following changes were made since the initial announcement:

  • The migrations are now performed inside a database transaction
  • Big code cleanup by adding all needed docstrings
  • When renaming a column, the data type is retained
  • You can now migrate up, down or to a specific version
  • You can now list the status of all migrations


Downloads are available on:

http://github.com/pi...i-dbmigrations/

The extension is also available in the Yii extensions directory under:

http://www.yiiframew...i-dbmigrations/

Cheers,


pieter
0

#12 User is offline   kalmenchia 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 02-February 09

Posted 02 July 2009 - 06:39 AM

Hi ,


I would like to try the extension , i have followed the steps until Configuring the command map and I am not too sure where I should put this to ...

'commandMap' => array(
    'migrate' => array(
        'class'=>'application.extensions.yii-dbmigrations.CDbMigrationCommand',
    ),
),


And I have tried put to config/main.php it is not working. Pls advice. Thanks.

0

#13 User is offline   pclaerhout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 08-December 08

Posted 02 July 2009 - 06:44 AM

You need to put this in the "protected/config/console.php" file.

cheers,

pieter
0

#14 User is offline   kalmenchia 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 02-February 09

Posted 02 July 2009 - 06:58 AM

Hi Pieter ,


Thanks , follow your instruction I got it working but seems that it calls only yiic.bat from within the application not the yii/framework/yiic.bat , if i call shell using yii/framework it is not working , so is it possible to get the yii-dbmigration to put into the yii/framework as all applications develop should use the same yii-dbmigration extension. ?

Thanks.
0

#15 User is offline   pclaerhout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 08-December 08

Posted 07 July 2009 - 08:04 AM

Hi kalmenchia,

as far as I know, there is no way (yet?) to install an extension sytem-wide without altering your install of the framework.

Cheers,


pieter
0

#16 User is offline   yingyang 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 19-March 09

Posted 30 July 2009 - 07:03 AM

I think people are using symlinks to reduce redundancy in filesystem for multiple apps.
0

#17 User is offline   GodFather 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 91
  • Joined: 19-July 09

Posted 11 August 2009 - 04:45 PM

Wow, work like rails, but I have one question:

How can I generate automatic blank migration files?

To simplify the naming of files.

Thanks.
0

#18 User is offline   pclaerhout 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 25
  • Joined: 08-December 08

Posted 14 August 2009 - 02:55 PM

View PostGodFather, on 11 August 2009 - 04:45 PM, said:

Wow, work like rails, but I have one question:

How can I generate automatic blank migration files?

To simplify the naming of files.

Thanks.


If you download the latest version from github, you will see that I added a new command that creates a blank migration:

protected yiic migrate create MyTestMigration


That will create the timestamped file with an empty migration in there.

Regards,


pieter
0

#19 User is offline   me23 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 45
  • Joined: 20-October 08
  • Location:Germany

Posted 14 August 2009 - 03:53 PM

Hi,

i have a little feature request:
I would like to configure more databases for
one project e.g production, testing, development
and therefore i need the opportunity to migrate
to given version and given environment e.g.
yiic migrate env=testing for migrating the testing database

Thanks for sharing your great work!

Greetings from Germany

me23
0

#20 User is offline   GodFather 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 91
  • Joined: 19-July 09

Posted 16 August 2009 - 04:51 PM

Actually I'm using a older version of this extension.

How can I update this extencion in my aplications? Just overwrite the classes in extensio directory?

Thanks.
0

Share this topic:


  • (3 Pages)
  • +
  • 1
  • 2
  • 3
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users