2

I replicated what was mentioned here: (Plugins: Managing Related Records)

However I'm not seeing any new table created to on plugin install.

I have a "LeaderRecord" with

'trips'     => [static::MANY_MANY, 'pluginexample_TripRecord', 'pluginexample_trip_leaders(tripId, leaderId)']

with the same relation defined in a "TripRecord", am I missing something to have the tabled created?

Thanks!

4
  • First – your record(s) will only create tables when the plugin is first installed, so if your plugin is already installed, you'll need to un- and reinstall it. Secondly, I believe your record's class name (second parameter) should be PluginExample_TripRecord. Apr 26 '15 at 8:36
  • I only used that name to obfuscate clients name - It is capitalized in actual. I have uninstalled and re-installed and still don't seem to be getting the PluginExample_trip_leaders table. Apr 26 '15 at 8:49
  • I might've misinterpreted your issue - both tables needs their own record. Simply defining relations in one record won't create another table. Apr 26 '15 at 9:08
  • If you already have two record classes, I'd suggest adding them both – in full – to your question, it'll probably make figuring out your issue much easier. Apr 26 '15 at 16:40
2

Craft won't create the join table for you when specifying a MANY_MANY relationship. You'll still need to manually create a record for that join table. See Craft's own craft/app/records/UserGroup_UserRecord.php as an example.

What it will do, as mentioned in the answer you linked to is keep the data up-to-date in the join table without having to specifically reference it in your queries.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.