Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-12-12 22:09:38

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

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

#2 2007-12-12 22:50:36

ruud
Developer Emeritus
From: a galaxy far far away
Registered: 2006-06-04
Posts: 5,068
Website

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

#3 2007-12-12 23:14:37

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

Re: creating and upgrading a table for a plugin

  1. it is – thanks again Ruud!

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

#5 2007-12-13 04:28:15

variaas
Plugin Author
From: Chicago
Registered: 2005-01-16
Posts: 402
Website

Re: creating and upgrading a table for a plugin

I agree Steve – I’ll be offering both install and uninstall links from the help page.

Offline

Board footer

Powered by FluxBB