PDA

View Full Version : خطا در زمان اجرای migrate (حل شد)



zahra6377
سه شنبه 17 تیر 1393, 11:46 صبح
سلام
موقع اجرای migrate این خطا رو میده،قبلا یکی دیگه ارا کردم دست بود اما الان خطا میده،مشکل از کجاست؟
ممنونم
120889

under22
سه شنبه 17 تیر 1393, 12:01 عصر
شما کد migration رو بزارید بررسی بشه

zahra6377
سه شنبه 17 تیر 1393, 12:20 عصر
ممنون ،اینم کد

<?php

class m120511_173401_create_issue_user_and_assignment_ta bles extends CDbMigration
{
// Use safeUp/safeDown to do migration with transaction
public function safeUp()
{
//create the issue table
$this->createTable('tbl_issue', array(
'id' => 'pk',
'name' => 'string NOT NULL',
'description' => 'text',
'project_id' => 'int(11) DEFAULT NULL',
'type_id' => 'int(11) DEFAULT NULL',
'status_id' => 'int(11) DEFAULT NULL',
'owner_id' => 'int(11) DEFAULT NULL',
'requester_id' => 'int(11) DEFAULT NULL',
'create_time' => 'datetime DEFAULT NULL',
'create_user_id' => 'int(11) DEFAULT NULL',
'update_time' => 'datetime DEFAULT NULL',
'update_user_id' => 'int(11) DEFAULT NULL',
), 'ENGINE=InnoDB');

//create the user table
$this->createTable('tbl_user', array(
'id' => 'pk',
'username' => 'string NOT NULL',
'email' => 'string NOT NULL',
'password' => 'string NOT NULL',
'last_login_time' => 'datetime DEFAULT NULL',
'create_time' => 'datetime DEFAULT NULL',
'create_user_id' => 'int(11) DEFAULT NULL',
'update_time' => 'datetime DEFAULT NULL',
'update_user_id' => 'int(11) DEFAULT NULL',
), 'ENGINE=InnoDB');

//create the assignment table that allows for many-to-many relationship between projects and users
$this->createTable('tbl_project_user_assignment', array(
'project_id' => 'int(11) DEFAULT NULL',
'user_id' => 'int(11) DEFAULT NULL',
'PRIMARY KEY (`project_id`,`user_id`)',
), 'ENGINE=InnoDB');

//foreign key relationships

//the tbl_issue.project_id is a reference to tbl_project.id
$this->addForeignKey("fk_issue_project", "tbl_issue", "project_id", "tbl_project", "id", "CASCADE", "RESTRICT");

//the tbl_issue.owner_id is a reference to tbl_user.id
$this->addForeignKey("fk_issue_owner", "tbl_issue", "owner_id", "tbl_user", "id", "CASCADE", "RESTRICT");

//the tbl_issue.requester_id is a reference to tbl_user.id
$this->addForeignKey("fk_issue_requester", "tbl_issue", "requester_id", "tbl_user", "id", "CASCADE", "RESTRICT");

//the tbl_project_user_assignment.project_id is a reference to tbl_project.id
$this->addForeignKey("fk_project_user", "tbl_project_user_assignment", "project_id", "tbl_project", "id", "CASCADE", "RESTRICT");

//the tbl_project_user_assignment.user_id is a reference to tbl_user.id
$this->addForeignKey("fk_user_project", "tbl_project_user_assignment", "user_id", "tbl_user", "id", "CASCADE", "RESTRICT");

}

public function safeDown()
{
$this->truncateTable('tbl_project_user_assignment');
$this->truncateTable('tbl_issue');
$this->truncateTable('tbl_user');
$this->dropTable('tbl_project_user_assignment');
$this->dropTable('tbl_issue');
$this->dropTable('tbl_user');
}

}

under22
سه شنبه 17 تیر 1393, 12:28 عصر
این کد ها رو اگه از پکیج کپی کردی مشکلی نداره .
تو خطا بالا گفته شده tableperfix رو تعریف نکردید

zahra6377
سه شنبه 17 تیر 1393, 12:45 عصر
ولی تعریف شده هم توی main و هم توی consol

Veteran
سه شنبه 17 تیر 1393, 15:18 عصر
بله تعریف شده، اما غلط نوشتاری دارین
شما نوشتین tableperfix در صورتی که باید بنویسین tablePrefix

zahra6377
سه شنبه 17 تیر 1393, 15:47 عصر
اره توی کنسول اشتباه بود اینجا هم اشتباه ممنون درست شد:لبخندساده: