Yii Framework Forum: Yiic Migration - Yii Framework Forum

Jump to content

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

Yiic Migration Rate Topic: -----

#1 User is offline   Sammuner 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 04-September 12

Posted 03 January 2013 - 07:37 PM

Hi,
I'm new here.
I'm going tru =remchi.ru Yii Quani #02: User Sign Up

yiic migrate create new_users_table (creates migrate file)

migrate file content
<?php

class m130104_000105_new_users_table extends CDbMigration
{

	public function safeUp()
	{
		$this->createTable('users', array(
            'id' => 'pk',
            'username' => 'string NOT NULL',
			'crypted_password' => 'string NOT NULL',
			'salt' => 'string NOT NULL',
			'email' => 'string NOT NULL',
            'active' => 'boolean',
            'create_time' => 'integer NOT NULL',
            'rating' => 'integer'
        ));
	}

	public function safeDown()
	{
$this->dropTable('users');
	}

}


but when i try to run yiic migrate, i always get this error:

Yii Migration Tool v1.0 (based on Yii v1.1.13)

Creating migration history table "tbl_migration"...exception 'CDbException' with message 'CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is
767 bytes. The SQL statement executed was: CREATE TABLE `tbl_migration` (
        `version` varchar(255) NOT NULL PRIMARY KEY,
        `apply_time` int(11)
)' in J:\xampp\htdocs\w\framework\db\CDbCommand.php:357
Stack trace:
#0 J:\xampp\htdocs\w\framework\db\CDbCommand.php(1321): CDbCommand->execute()
#1 J:\xampp\htdocs\w\framework\cli\commands\MigrateCommand.php(471): CDbCommand->createTable('tbl_migration', Array)
#2 J:\xampp\htdocs\w\framework\cli\commands\MigrateCommand.php(454): MigrateCommand->createMigrationHistoryTable()
#3 J:\xampp\htdocs\w\framework\cli\commands\MigrateCommand.php(482): MigrateCommand->getMigrationHistory(-1)
#4 J:\xampp\htdocs\w\framework\cli\commands\MigrateCommand.php(84): MigrateCommand->getNewMigrations()
#5 [internal function]: MigrateCommand->actionUp(Array)
#6 J:\xampp\htdocs\w\framework\console\CConsoleCommand.php(172): ReflectionMethod->invokeArgs(Object(MigrateCommand), Array)
#7 J:\xampp\htdocs\w\framework\console\CConsoleCommandRunner.php(67): CConsoleCommand->run(Array)
#8 J:\xampp\htdocs\w\framework\console\CConsoleApplication.php(91): CConsoleCommandRunner->run(Array)
#9 J:\xampp\htdocs\w\framework\base\CApplication.php(169): CConsoleApplication->processRequest()
#10 J:\xampp\htdocs\w\framework\yiic.php(33): CApplication->run()
#11 J:\xampp\htdocs\w\webapp\protected\yiic.php(7): require_once('J:\xampp\htdocs...')
#12 {main}
J:\xampp\htdocs\w\webapp\protected>


yii 1.1.13, windows 7, xampp

tryed using documentation exsample

class m101129_185401_create_news_table extends CDbMigration
{
    public function safeUp()
    {
        $this->createTable('tbl_news', array(
            'id' => 'pk',
            'title' => 'string NOT NULL',
            'content' => 'text',
        ));
    }
 
    public function safeDown()
    {
        $this->dropTable('tbl_news');
    }
}


same error


Fixed, by creating db one more time..
0

#2 User is offline   Saman Shafigh 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 11-September 13

Posted 12 September 2013 - 11:41 PM

Thank you so much.
0

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