Yii 마이그레이션에 문제가 있습니다. 문제는 내가 성공적으로 마이 그 레이션 한 후에 다른 마이 그 레이션 코드를 시도한 코드를 마이 그 레이션했지만 마이 그 레이션 코드, 내가 처음 마이 그 레이션 한 첫 번째 마이 그 레이션 해야하는 두 번째 보여 주었다. 나는 계속해서 yii에게 마이그레이션을 계속하라고 말했고, 그 후에 마이 그 레이션이 이미 완료되었다는 오류가 발생했습니다. 이제는 이미 수행 한 마이 그 레이션 이었기 때문에 두 번째 마이 그 레이션을 수행 할 수 없었습니다. 그런 다음 첫 번째 마이그레이션 코드를 삭제하고 두 번째 코드를 마이그레이션했습니다. 코드가 성공적으로 실행되었지만 테이블이 작성되지 않았습니다. 누구든지 내 마이그레이션이 수행되고 있지 않은 이유와 해결 된 두 번째 코드, 테이블이 마이그레이션 폴더의 safeup() 및 safedown()에있는 마지막 솔루션 인 이유에 대한 해결책이 있습니까?Yii 마이그레이션이 작동하지 않습니다.
이것은 내 코드이지만 다시 오류가 발생합니다. 실제로 저는 trackstar 프로젝트에서 yii를 배웁니다. 그래서,이 내 코드를 다시, 나는 위로 함수에 다시 오류가 보관. 당신은 잘 마이그레이션 코드가이 지금 저를 보여주는 시작 오류입니다 최대 붙여 넣은 모습
public function up()
{
//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) NOT NULL',
'user_id' => 'int(11) NOT 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 totbl_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 down()
{
$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');
}
`
을 가질 수있다. Dropbox에 대한 링크를 여기에 표시했습니다. enter link description here
지금은 마이그레이션이 실패했다는 오류가 있습니다. 모든 이후의 마이 그 레이션이 취소됩니다 –
데이터베이스의 생성에 @Ivan Buttinoni의 http://stackoverflow.com/questions/17444095에 대한 응답이 필요없는 경우 안전 방법 대신 업 방법에 코드를 넣으려고 할 수 있습니다./yii-migration-tables-are-not-created. 오류가있는 경우 여기에 붙여 넣으십시오. . – hsabbagh
나는 yiic 마이 그 레이션 다운 함수를 사용했습니다. –