On Mon, Sep 17, 2012 at 11:12 AM, Ethan Jucovy <ethan.juc...@gmail.com>wrote:
> For setting up database tables in plugins, I've used TracHoursPlugin as an > example/template/thing-to-cargo-cult-from. It uses a helper library > (TracSqlHelperScript) that abstracts out a create_table function, but if > you don't feel like making that a dependency of your plugin, it's only a > few lines of code that you can copy over; your code will end up looking > something like [snip] > Or, if you *do* feel like just adding a dependency on TracSqlHelperScript, like I ended up doing, you could basically just copy all of the setup code in MultiRepoSearchPlugin here[1] and adjusting it for your needs. In addition to demonstrating schema definition and table creation, it also uses Trac's system table to track what upgrades need to occur, and a neat little upgrade-steps-based-on-current-version framework thingie that I copied from TracHours. (That's the `version()` and `steps =` stuff.) I *think* this is considered The Right Way to manage upgrades in Trac plugins these days. [1] https://github.com/boldprogressives/trac-MultiRepoSearchPlugin/blob/master/multireposearch/sqlindexer.py -- You received this message because you are subscribed to the Google Groups "Trac Development" group. To post to this group, send email to trac-dev@googlegroups.com. To unsubscribe from this group, send email to trac-dev+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/trac-dev?hl=en.