2011-04-26 58 views
0

我目前使用的sfDoctrineGuardPluginsfForkedDoctrineApplyPlugin,當我重新載入數據使用doctrine:data-load的symfony - sfDoctrineGuard - 承載夾具數據

我得到如下:

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails ( MY_DB . sf_guard_user_profile , CONSTRAINT sf_guard_user_profile_user_id_sf_guard_user_id_1 FOREIGN KEY ( USER_ID ) REFERENCES sf_guard_user (編號) ON DELETE CASCADE)

這真的很煩人,因爲我不能加載我的燈具中的任何記錄。

我已經複製從sfForkedDoctrineApplyPlugin架構和擴展它一點點:

sfGuardUserProfile: 
    actAs: 
    Timestampable: ~ 
    columns: 
    user_id: 
     type: bigint(20) 
     notnull: true 
     default: 
     unsigned: false 
     primary: false 
     unique: false 
     autoincrement: false 
    email_new: 
     type: string(255) 
     unique: true 
    firstname: 
     type: string(255) 
    lastname: 
     type: string(255) 
    city: 
     type: varchar(255) 
    validate_at: 
     type: timestamp 
    validate: 
     type: string(33) 
    relations: 
    User: 
     class: sfGuardUser 
     foreign: id 
     local: user_id 
     type: one 
     onDelete: cascade 
     foreignType: one 
     foreignAlias: Profile 
    indexes: 
    validate: 
     fields: [validate] 

有誰知道如何解決這一問題?

感謝

+0

加載兩個或更多批次的燈具 - 以加載父數據之前加載子數據,尊重您的表之間的關係。這就是錯誤所在。 – Tom 2011-04-26 13:13:10

+0

但是已經從sf_guard_user生成了這些修復程序的加載。我手動添加這些用戶在管理員,只是'數據轉儲',然後嘗試'數據加載'在另一個數據庫。 – 2011-04-26 13:34:03

回答

0

好了不兼容,所以我不得不整數(11)添加到所有的sfDoctrineGuardPlugin中的表。有點不好意思,但現在起作用

0

在你的固定裝置sfGuardUserProfile你需要爲你有一個外國鏈接到它不能爲空

sfGuardUserProfile: 
    bob_profile: 
     sfGuardUser: bob # Set the link 
     firstname: bob 
     # bobs_profile fixtures 


sfGuardUser: 
    bob: 
     # bobs fixtures 
+0

這些燈具已經由我通過管理員中的sfGuardUser添加用戶而生成,所以我希望他們有鏈接! – 2011-04-26 12:36:59

+0

所以你做了一個數據轉儲來生成燈具? – 2011-04-26 12:39:59

+0

是的,我做到了。無論如何,在'data.yml'看我有這樣的東西:http://pastebin.com/UxKnHftm – 2011-04-26 12:42:43

0

檢查用戶的ID類型指定sfGuardUser鏈接。 它必須是一樣sfGuardUserProfile user_id是:BIGINT(20)

+0

一切似乎是一個bigint(20) – 2011-04-26 12:42:59

1
user_id: 
    type: bigint(20) 

IST到sfGuardUser

sfGuardUser: 
    type: integer()