0

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?

user2492854
  • 401
  • 2
  • 12
  • 32

1 Answers1

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