HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.

Extension database tables - creation and deletion

edited August 2008 in Vanilla 1.0 Help
Is there a best practice or de facto standard by which extensions should add database tables? I am preparing an extension for release and want to make it as clean as possible, including this step. Right now, I have a .sql file that would be bundled with it, along with instructions to pipe the file into a mysql client. If there is a better way, I'm all ears. Also, I don't suppose there is any delegate or other way for an extension to perform actions when it is removed, such as dropping tables that only exist for its benefit. If there is, let me know that, too. I'm excited about releasing my first extension here. Thanks for the help! :)

Comments

  • I think you have it backwards. Setting up the extension should be as automated as possible; many (most?) Vanilla admins are not comfortable with SQL. Cleaning up tables when the extension is removed should be manual; admins need a way to temporarily "neutralize" an extension (like when dealing with conflicts) without nuking all of its settings and db tables.

    The usual way handle new table setup is with something like this at the beginning of your default.php:
    if ( !isset($Configuration['MYEXTENSION_VERSION']) ) { ... create tables, define default settings, etc... AddConfigurationSetting($Context, 'MYEXTENSION_VERSION'); }

    As for removing it, put some instructions for manual removal into your README. That way anyone who is truly concerned about cleanup has the info to take care of it themselves.
  • I actually switched to that method last night, although you're right that I should add something in the README about removing the tables. :)
This discussion has been closed.