Yii Framework Forum: Yii-User Installation Bug, 'unrecognized Token' At Yiic Migrate - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Yii-User Installation Bug, 'unrecognized Token' At Yiic Migrate

#1 User is offline   fernacolo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 12-November 12

Posted 13 November 2012 - 07:17 AM

Hi there!

First of all, when I fetched last version of yii-user from GIT (github.com, mishamx, yii-user) into my protected/modules directory, it creates a directory called 'yii-user' which appears to be a module. But the entire yii-user documentation uses 'user' as module name, so I decided to rename 'yii-user' to 'user' and many things started to work. If I was not supposed to rename, or having to rename, please tell me what I did wrong...

Second, and that's why I'm here, I'm getting the following error when I issue the migrate command:


*** applying m110810_162301_userTimestampFix
type db: sqlite
> add column create_at TIMESTAMP to table {{users}} ... done (time: 0.001s)
> add column lastvisit_at TIMESTAMP to table {{users}} ... done (time: 0.000s)
> execute SQL: UPDATE {{users}} SET create_at = datetime(createtime, 'unixepoch'), lastvisit_at = datetime(lastvisit, 'unixepoch') ...Exception: CDbCommand failed to execute the SQL statement: CDbCommand failed to prepare the SQL statement: SQLSTATE[HY000]: General error: 1 unrecognized token: "{". The SQL statement executed was: UPDATE {{users}} SET create_at = datetime(createtime, 'unixepoch'), lastvisit_at = datetime(lastvisit, 'unixepoch') (C:\xampp\yii-1.1.12.b600af\framework\db\CDbCommand.php:354)
#0 C:\xampp\yii-1.1.12.b600af\framework\db\CDbMigration.php(160): CDbCommand->execute(Array)
#1 C:\phpprojects\testdrive\protected\modules\user\migrations\m110810_162301_userTimestampFix.php(32): CDbMigration->execute('UPDATE {{users}...')
#2 C:\xampp\yii-1.1.12.b600af\framework\db\CDbMigration.php(51): m110810_162301_userTimestampFix->safeUp()
#3 C:\xampp\yii-1.1.12.b600af\framework\cli\commands\MigrateCommand.php(386): CDbMigration->up()
#4 C:\xampp\yii-1.1.12.b600af\framework\cli\commands\MigrateCommand.php(110): MigrateCommand->migrateUp('m110810_162301_...')
#5 [internal function]: MigrateCommand->actionUp(Array)
#6 C:\xampp\yii-1.1.12.b600af\framework\console\CConsoleCommand.php(173): ReflectionMethod->invokeArgs(Object(MigrateCommand), Array)
#7 C:\xampp\yii-1.1.12.b600af\framework\console\CConsoleCommandRunner.php(68): CConsoleCommand->run(Array)
#8 C:\xampp\yii-1.1.12.b600af\framework\console\CConsoleApplication.php(92): CConsoleCommandRunner->run(Array)
#9 C:\xampp\yii-1.1.12.b600af\framework\base\CApplication.php(162): CConsoleApplication->processRequest()
#10 C:\xampp\yii-1.1.12.b600af\framework\yiic.php(34): CApplication->run()
#11 C:\phpprojects\testdrive\protected\yiic.php(7): require_once('C:\xampp\yii-1....')
#12 {main}
*** failed to apply m110810_162301_userTimestampFix (time: 0.113s)

Migration failed. All later migrations are canceled.

Am I missing some step, or is this a yii-user bug?

#2 User is offline   fernacolo 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 12-November 12

Posted 13 November 2012 - 07:39 AM

Hi. I figured out the problem. The db configuration of protected/config/console.php was wrong. As a newbie, I only configured db for protected/config/main.php. I guess that yiic migrate uses console.php configurations.

Solved now! Hope this is useful for someone else.

#3 User is offline   LarryTX 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 35
  • Joined: 22-June 10

Posted 14 June 2013 - 09:59 AM

When I attempt to run the migration, it fails when attempting to apply m110810_162301_userTimestampFix. The error message is

 > execute SQL: UPDATE {{users}} SET create_at = FROM_UNIXTIME(c
 IF(lastvisit,FROM_UNIXTIME(lastvisit),'0000-00-00 00:00:00') ..
led to execute the SQL statement: SQLSTATE[42000]: Syntax error
You have an error in your SQL syntax; check the manual that corr
er version for the right syntax to use near '{users}} SET create
time), lastvisit_at = IF(lastvisit,' at line 1. The SQL statemen
sers}} SET create_at = FROM_UNIXTIME(createtime), lastvisit_at =
E(lastvisit),'0000-00-00 00:00:00') (L:\xampp\framework\db\CDbCo
L:\xampp\framework\db\CDbMigration.php(159): CDbCommand->execute
x.php(24): CDbMigration->execute('UPDATE {{users}...')
L:\xampp\framework\db\CDbMigration.php(50): m110810_162301_userT
L:\xampp\framework\cli\commands\MigrateCommand.php(385): CDbMigr
L:\xampp\framework\cli\commands\MigrateCommand.php(109): Migrate
[internal function]: MigrateCommand->actionUp(Array)
L:\xampp\framework\console\CConsoleCommand.php(172): ReflectionM
igrateCommand), Array)
L:\xampp\framework\console\CConsoleCommandRunner.php(67): CConso
L:\xampp\framework\console\CConsoleApplication.php(91): CConsole

L:\xampp\framework\base\CApplication.php(169): CConsoleApplicati
 L:\xampp\framework\yiic.php(33): CApplication->run()
 L:\xampp\htdocs\larrylutz\protected\yiic.php(7): require_once('
 failed to apply m110810_162301_userTimestampFix (time: 0.196s)

Also, are the tables created really supposed to be named {{profiles_fields}}, {{profiles}}, {{users}} (with the braces just as typed)? That's what the migration created, and those names look really strange to me.

Share this topic:

Page 1 of 1
  • 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