In my web application I have made some changes in the mysql database and I want to reflect the same changes in my web application. I know I can use database migration, but where should I run the command for a migration ? should I create a program in /migrations directory for altering table, if so where should I run the command "yiic migrate" to reflect the changes? how should I resolve this?
Asked
Active
Viewed 1,229 times
0
-
you run it from where yiic resides. – Pentium10 Feb 11 '14 at 06:39
1 Answers
0
You're going to need terminal or some command line interface. In there you would type (for example):
php /Users/Name/Sites/SiteDir/public_html/protected yiic migrate create table_changes
That will create a new, blank migration called 'table_changes' in the protected/migrations folder. If you encounter any errors, make sure that the console config file that yiic.php uses has the correct DB settings for your environment, and includes a reference to the migration class:
'commandMap'=>array(
'migrate'=>array(
'class'=>'system.cli.commands.MigrateCommand',
'migrationPath'=>'application.migrations',
'migrationTable'=>'yii_migration',
'connectionID'=>'db',
),
),
I would recommend making all DB changes via a migration first - that way you're 'eating your own dog food' and making sure it works.
More information about creating and running Yii migrations

JamesG
- 1,687
- 2
- 25
- 39