Upgrade Fails Due to Foreign Key Constraint in the PAGETEMPLATES Table

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

症状

Upgrade fails. The following appears in the atlassian-confluence.log:

Cannot add or update a child row: a foreign key constraint fails (`confluencedb/#sql-214_69ba`, CONSTRAINT `FKBC7CE96A17D4A070` FOREIGN KEY (`PREVVER`) REFERENCES `pagetemplates` (`TEMPLATEID`))

原因

It means there is a row in the PAGETEMPLATES table where its prevver column does not exist in the templateid column. This is a constraint violation.

ソリューション

データベースを変更する前には必ずデータをバックアップするようにします。

  1. Roll back database to the previous state (before upgrade)

  2. Search for the rogue row by running:

    select * from pagetemplates where prevver not in (select templateid from pagetemplates);
    
  3. Delete it after making a backup of your database:

    delete from pagetemplates where templateid is in (select templateid from pagetemplates where prevver not in (select templateid from pagetemplates));

    tip/resting Created with Sketch.

    If you are using MySQL, the delete command above will fail. The work around is to delete the problematic template one by one:

    delete from pagetemplates where templateid = <template_id>;

    <template_id> is the value for templateid returned from the select query.

  4. Re-run the upgrade
最終更新日 2018 年 11 月 14 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.