| 1 | use strict; | ||
| 2 | use warnings; | ||
| 3 | |||
| 4 | package Jifty::Upgrade::Internal; | ||
| 5 | use Jifty::Upgrade; | ||
| 6 | use base qw/Jifty::Upgrade/; | ||
| 7 | use Jifty::Model::Metadata; | ||
| 8 | |||
| 9 | # XXX TODO: there's probably a cleaner way to cope than "INITIAL_VERSION", perhaps using ->VERSIONS | ||
| 10 | our $INITIAL_VERSION; | ||
| 11 | |||
| 12 | =head1 NAME | ||
| 13 | |||
| 14 | Jifty::Upgrade::Internal - Upgrades to Jifty-specific schema and data | ||
| 15 | |||
| 16 | =head1 UPGRADES | ||
| 17 | |||
| 18 | =head2 Version 0.60427 | ||
| 19 | |||
| 20 | Version metadata, previously stored in _db_version, get migrated to | ||
| 21 | _jifty_metadata, so it could be used to store more than one row | ||
| 22 | usefully. | ||
| 23 | |||
| 24 | =cut | ||
| 25 | |||
| 26 | since '0.60427' => sub { | ||
| 27 | my @v = Jifty->handle->fetch_result("SELECT major, minor, rev FROM _db_version"); | ||
| 28 | Jifty->handle->simple_query("DROP TABLE _db_version"); | ||
| 29 | Jifty::Model::Metadata->store( application_db_version => version->new(join'.',@v)); | ||
| 30 | # Since we broke things before 0.60504 but fixed them shortly thereafter, | ||
| 31 | # Make sure the user doesn't run the 060504 upgrade unless they must | ||
| 32 | $INITIAL_VERSION = '0.60427'; | ||
| 33 | }; | ||
| 34 | |||
| 35 | since '0.60504' => sub { | ||
| 36 | return if ($INITIAL_VERSION == '0.60427'); | ||
| 37 | rename column => 'key', in => 'Jifty::Model::Session', to => 'data_key'; | ||
| 38 | rename column => 'key', in => 'Jifty::Model::Metadata', to => 'data_key'; | ||
| 39 | }; | ||
| 40 | |||
| 41 | since '0.61025' => sub { | ||
| 42 | Jifty::Util->require('IPC::PubSub'); | ||
| 43 | IPC::PubSub->new( | ||
| 44 | JiftyDBI => ( | ||
| 45 | db_config => Jifty->handle->{db_config}, | ||
| 46 | table_prefix => '_jifty_pubsub_', | ||
| 47 | db_init => 1, | ||
| 48 | ) | ||
| 49 | ); | ||
| 50 | }; | ||
| 51 | |||
| 52 | since '0.61210' => sub { | ||
| 53 | Jifty::Util->require('IPC::PubSub'); | ||
| 54 | IPC::PubSub->new( | ||
| 55 | JiftyDBI => ( | ||
| 56 | db_config => Jifty->handle->{db_config}, | ||
| 57 | table_prefix => '_jifty_pubsub_', | ||
| 58 | db_init => 0, | ||
| 59 | ) | ||
| 60 | ); | ||
| 61 | |||
| 62 | rename column => 'key', in => 'IPC::PubSub::Cache::JiftyDBI::Stash::Item', to => 'data_key'; | ||
| 63 | }; | ||
| 64 | |||
| 65 | # Drop PubSub tables | ||
| 66 | |||
| 67 | 1; |