Thanks for the reply, Mark. Sorry for not posting code, but I had literally followed the example on the page I referenced to the tee. Anywho, here's my "upgrade_functions" setup:
upgrade_functions => {
'upgrade_to_1_1' => {
version_limit => 1.001, # schema 1.0001, plugin v1.1
updater => {
type => 'list',
label => 'Updating MailChimp ListDetails...',
condition => sub { 1; },
code => '$MailChimp::MailChimp::Utils::upgrade_to_1_1'
},
},
}
When I wrote 1st, it was:
code=> sub { //do stuff }
Just to follow the way you did it, I split off the code into another module. One thing I meant to ask the 1st time is what "type" is supposed to be. I've randomly swapped it around with different things - "list" is there now b/c it is the name of the object type the custom object I am messing with is defined as:
object_types => {
'list' => 'MailChimp::ListDetails',
},
I did stick some print STDERR lines in the function that references, but don't see anything occur.
On that note, it is completely possible that I'm missing something that should be logged or debugged - b/c I can't find *anything* anywhere. I remember getting stack traces & such on screen when I was writing this the 1st time, and still have DebugMode set to 3, but I don't see anything anywhere. I've actually had to add code back in line-by-line to see what caused the plugin to fail to load, which is wonky and tedious. Any suggestions for that would be wonderful. I'd love to just have it dumped in a file somewhere that I can tail.
thanks,
jesse
upgrade_functions => {
'upgrade_to_1_1' => {
version_limit => 1.001, # schema 1.0001, plugin v1.1
updater => {
type => 'list',
label => 'Updating MailChimp ListDetails...',
condition => sub { 1; },
code => '$MailChimp::MailChimp::Utils::upgrade_to_1_1'
},
},
}
When I wrote 1st, it was:
code=> sub { //do stuff }
Just to follow the way you did it, I split off the code into another module. One thing I meant to ask the 1st time is what "type" is supposed to be. I've randomly swapped it around with different things - "list" is there now b/c it is the name of the object type the custom object I am messing with is defined as:
object_types => {
'list' => 'MailChimp::ListDetails',
},
I did stick some print STDERR lines in the function that references, but don't see anything occur.
On that note, it is completely possible that I'm missing something that should be logged or debugged - b/c I can't find *anything* anywhere. I remember getting stack traces & such on screen when I was writing this the 1st time, and still have DebugMode set to 3, but I don't see anything anywhere. I've actually had to add code back in line-by-line to see what caused the plugin to fail to load, which is wonky and tedious. Any suggestions for that would be wonderful. I'd love to just have it dumped in a file somewhere that I can tail.
thanks,
jesse
On Thu, Aug 28, 2008 at 13:41, Mark Carey <mtpronet@...> wrote:
Jesse,
Its hard to be specific since you haven't posted any code but...
I don't think the MT api will remove the column. It is pretty good
add schema changes to add or modify existing columns, but I don't
think there is any logic in there to remove a column (but I am not
100% sure).
That said, since the new column is getting added, the remaining item is:And for this, your are correct, an upgrade function is the way to go.
> * for each Object, retrieve it and:
> - login to our web service to get the proper api_key
> - update the new column with the key
I can't comment on what isn't working for you, of course.
Here's an example from one my plugins:
snippet from my .pl file, to register the upgrade function"
'upgrade_functions' => {
'import_images' => {
version_limit => 1.231, # runs for schema_version < 1.231 --
plugin version 1.5x
updater => {
type => 'author',
label => 'Importing author photos...',
condition => sub { !$_[0]->userpic_asset_id },
code => '$UserProfile::UserProfiles::Pro::Util::import_images',
}
},
},
and the function itself:
sub import_images {
my ($author) = @_;
return if $author->userpic_asset_id;
...code here to import image, create asset, etc. (you api
fetching stuff would go here)
# now update the object
$author->userpic_asset_id($asset->id)
or MT->log("Error adding asset to author: " . $author->errstr);
$author->save;
}
As you work on it, try to log any errors to the MT activity log, or to
STDERR, as that can help identify issues along the way...
Hope this helps,
Mark
On Thu, Aug 28, 2008 at 2:02 PM, jesse <jessedp@...> wrote:
> Hello all. I'm putting out an updated version of our MT plugin and am having
> some issues with the upgrade scripts b/c I need to up the schema version.
> For the DB table change, I "simply" want to drop one column (a password
> field) and add another (an api key field). Because of that, I need to do
> something like this:
>
> * add the new column to the table
> * for each Object, retrieve it and:
> - login to our web service to get the proper api_key
> - update the new column with the key
> * drop the column from the table
>
> Honestly, I sincerely doubt anyone using this has actually set this up on
> more than one blog, so even adding/dropping the column during the "for each"
> would likely be fine, though I would rather do it right just in case.
>
> I've been trying to accomplish this using the "upgrade_functions" param when
> I init my plugin as shown here:
>
>
> http://www.movabletype.org/documentation/developer/movable-type-registry-reference.html
>
> Of course I've also updated my Custom Object's "install_properties",
> removing the one field & adding the other.
>
> So far the upgrade script is running, but this is all I see:
> ---
> * Upgrading table for mailchimp_list records...
> * Plugin 'MailChimp Subscribe Form' upgraded successfully to version 1.1
> (schema version 1.1).
> ---
> From what I can tell, my "updater" "code" is not being run at all. When I
> check the db table, I can see that the new column is added, but the old
> column is not being removed. Given that result, I'm pretty sure I could hack
> in some code to clean things up in my plugin code, but I'd really rather do
> it the right way.
>
> I've really tried digging through some other plugins and the core MT code,
> and am just not having any luck figuring this out.
>
> Oh, also, I'm running MT 4.1.
>
> Any help or suggestions anyone can provide would be greatly appreciated.
>
> thanks,
>
>
> jesse
>
>