Yii Migration, Tables are not created

后端 未结 7 1932
日久生厌
日久生厌 2021-01-03 15:34

I am new to Yii(Still Learning) I am following a book tutorial here I did as it was written in the book created a new migrate

yiic migrate create create_issu         


        
7条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-03 15:56

    Make sure you haven't created the tbl_user or tbl_issue tables manually via MySQL. If they exist already, drop them and then run your migration again.

    Also check to make sure your database connection strings in main/config.php AND main/console.php are set up to correctly reference the database the migration should use.

    To confirm that it worked, when your migration actually succeeds, you'll get results very similar to the following, listing each SQL action taken. If you don't see any actions taken in the list, it didn't run correctly.

    D:\xampp\htdocs\yii\trackstar\protected>yiic migrate
    
    Yii Migration Tool v1.0 (based on Yii v1.1.14)
    
    Total 1 new migration to be applied:
        m140406_014347_create_user_issue_assignment_tables
    
    Apply the above migration? (yes|no) [no]:y
    *** applying m140406_014347_create_user_issue_assignment_tables
        > create table tbl_issue ... done (time: 0.351s)
        > create table tbl_user ... done (time: 0.405s)
        > create table tbl_project_user_assignment ... done (time: 0.366s)
        > add foreign key fk_issue_project: tbl_issue (project_id) references tbl_pr
    oject (id) ... done (time: 0.923s)
        > add foreign key fk_issue_owner: tbl_issue (owner_id) references tbl_user (
    id) ... done (time: 1.066s)
        > add foreign key fk_issue_requester: tbl_issue (requester_id) references tb
    l_user (id) ... done (time: 1.829s)
        > add foreign key fk_project_user: tbl_project_user_assignment (project_id)
    references tbl_project (id) ... done (time: 1.416s)
        > add foreign key fk_user_project: tbl_project_user_assignment (user_id) ref
    erences tbl_user (id) ... done (time: 1.032s)
    *** applied m140406_014347_create_user_issue_assignment_tables (time: 7.446s)
    
    
    Migrated up successfully.
    

    Finally, creation of tables in MySQL will implicitly commit after they're run, so running your code in the safeDown() and safeUp() methods, which will run your code as MySQL transactions, isn't especially useful. For simplicity, I would move the code in each safe method to the respective "non-safe" method.

提交回复
热议问题