Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
creating and upgrading a table for a plugin
So I’ve written a plugin that requires an additional table in TXP. As the plugin evolves I may need to add more columns to the table so with future releases I have to verify that the existing table matches the required table structure. I’m trying to determine the most efficient way of doing this. I have two options and wanted to see if anyone could think of a third or just better way of verifying:
1. Every time the plugin is called I pull a list of all the columns in the table and do a diff against a hardcoded array of required columns. If something is missing then I do alter the table to add the columns.
2. I store a version number of the table in TXP preferences and everytime the plugin is called I compare that version number against a hardcoded version number in the plugin. If they are different then I do #1.
Option #2 reads like it might put less strain on a server, but I’m more how others would approach this problem.
Thanks!
Offline
Re: creating and upgrading a table for a plugin
definitely not #1.
#3 provide a link in the plugin help that triggers an upgrade process. People should really read plugin documentation.Offline
Offline
#4 2007-12-13 00:33:05
- net-carver
- Archived Plugin Author
- Registered: 2006-03-08
- Posts: 1,648
Re: creating and upgrading a table for a plugin
Amit
If you’re going to release this plugin then I’d add to Ruud’s suggestion: also add an uninstall link to remove your table too and cleanup anything else that might be hanging around.
— Steve
Offline
Offline