symfonyでリレーションがうまく貼れない件について
自分はDB構築するときはDBDesignerで設計してから
SQLをエクスポートして、テーブルを作成しているのですが、
外部キーを設定していても…
symfonyでsymfony propel-build-schema
を実行すると、発行されたschema.ymlの中には外部キー情報が消えてます!
これを解決するのに生成されたschema.ymlをちょっと弄りました。
char_tbl: _attributes: idMethod: native id: type: INTEGER required: true autoIncrement: true primaryKey: true member_tbl_id: type: INTEGER required: true default: story_tbl_id: type: INTEGER required: true default:
↑before ↓after
char_tbl: _attributes: idMethod: native id: type: INTEGER required: true autoIncrement: true primaryKey: true member_tbl_id: story_tbl_id:
どうやら、symfonyの場合、DB設計した時点で外部キーを指定していなくても
対応したテーブルのID(member_tblがあった場合member_tbl_id)などとして、
外部キー貼りたいテーブルにカラムを用意しておくだけで
勝手にpropel-build-modelする時に貼ってくれるとのことです。