Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Extending core tables in plugins

judgejjudgej
edited September 2010 in Vanilla 2.0 - 2.8
Many (if not most) modules in Vanilla 1 messed around with the core tables, often adding columns here and there where they were needed. Vanilla 2 plugins don't seem to do that. Is that a new coding standard for Vanilla, or frowned upon, or just something I have not yet encountered?

Adding metadata to users is easy now due to the helper classes that manage all that. How about discussions and comments? If I want to add a few flags to the comments for use in my plugin, is the standard here to create a new table and add the properties to that, linking by comment and discussion IDs?

Comments

  • Just on the subject of user data, users have settings in the user table (a serialized array - fast but nasty to handle outside of PHP) and there is a separate metadata table. Do they both service essentially the same purpose, or is there a subtle difference?
  • TimTim Operations Vanilla Staff
    We made UserMeta to help plugin devs handle user data in a clean way. Gdn_Plugin contains methods that handle this for you.

    As for extending core tables, IPTracking plugin does this:
    $Structure = Gdn::Structure(); $Structure ->Table('User') ->Column('LastIP', 'varchar(14)', TRUE) ->Set(FALSE, FALSE);

    "Add a column called LastIP to the User (GDN_User) table as a varchar(14) which CAN be NULL".

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • Thanks. It still does not feel right extending a core table for a plugin, but it doesn't half make querying, setting and sorting that data easier that using additional tables (which, often being 1:1 relationships, also does not feel right).
  • TimTim Operations Vanilla Staff
    Choose the way you like to work :)

    Vanilla Forums COO [GitHub, Twitter, About.me]

Sign In or Register to comment.