lundi, mars 17, 2008

Migration "Pas à pas" d'une application ruby on rails de 1.2.2 vers 1.2.6

Comment migrer "Pas à pas" une application ruby on rails de 1.2.2 vers 1.2.6 (Nous verrons de 1.2.6 à 2.0.2 dans un autre post).

Extrait du blog officiel de Ruby on Rails:
So how do I upgrade? If you want to move your application to Rails 2.0, you should first move it to Rails 1.2.6. That’ll include deprecation warnings for most everything we yanked out in 2.0. So if your application runs fine on 1.2.6 with no deprecation warnings, there’s a good chance that it’ll run straight up on 2.0. Of course, if you’re using, say, pagination, you’ll need to install the classic_pagination plugin. If you’re using Oracle, you’ll need to install the activerecord-oracle-adapter gem. And so on and so forth for all the extractions.

> ruby script\about

About your application's environment
Ruby version                 1.8.6 (i386-mswin32)
RubyGems version             1.0.1
Rails version                1.2.2
Active Record version        1.15.2
Action Pack version          1.13.2
Action Web Service version   1.2.2
Action Mailer version        1.3.2
Active Support version       1.4.1
Edge Rails revision          64
Application root             C:/developement/ruby/prophet/trunk/prophet
Environment                  development
Database adapter             mysql
Database schema version      8



> rake rails:unfreeze

> gem install rails --version 1.2.6

> gem list rails

*** LOCAL GEMS ***

rails (2.0.2, 1.2.6)

> edit appli/config/environment.rb
Changer:
RAILS_GEM_VERSION = '1.2.2' unless defined? RAILS_GEM_VERSION
En:
RAILS_GEM_VERSION = '1.2.6' unless defined? RAILS_GEM_VERSION

> rake rails:update:configs

modifie config/boot.rb

> rake rails:update:javascripts

modifie rien ?

> rake rails:update:scripts

modifie rien ?

> rake log:clear tmp:clear db:test:purge

> ruby script\about

About your application's environment
Ruby version                 1.8.6 (i386-mswin32)
RubyGems version             1.0.1
Rails version                1.2.6
Active Record version        1.15.6
Action Pack version          1.13.6
Action Web Service version   1.2.6
Action Mailer version        1.3.6
Active Support version       1.4.4
Application root             C:/developement/ruby/prophet/trunk/prophet
Environment                  development
Database adapter             mysql
Database schema version      8


> rake test
...
36 tests, 95 assertions, 0 failures, 0 errors
...
33 tests, 63 assertions, 0 failures, 0 errors

> ruby script\server
=> Booting Mongrel (use 'script/server webrick' to force WEBrick)
=> Rails application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment...
** Rails loaded.
** Loading any Rails specific GemPlugins
** Signals ready.  INT => stop (no restart).
** Mongrel 1.1.4 available at 0.0.0.0:3000
** Use CTRL-C to stop.
March 17, 2008 17:39 --

...

Regarder dans les logs s'il y a des "DEPRECATION WARNING"
Jeter un coup d'oeil à http://www.rubyonrails.org/deprecation
Installer le plugin deprecated: http://nubyonrails.com/articles/deprecated-plugin-find-old-rails-code
> ruby script/plugin install http://topfunky.net/svn/plugins/deprecated
+ ./deprecated/CHANGELOG
+ ./deprecated/MIT-LICENSE
+ ./deprecated/README
+ ./deprecated/about.yml
+ ./deprecated/tasks/deprecated.rake


> rake deprecated
(in C:/.../app)
--> component
 Clean! Cheers for you!

--> @session
 Clean! Cheers for you!

--> paginate
 Clean! Cheers for you!
...
S'il n'y a que des "Clean" c'est que tout va bien :)
> svn cleanup .
(optionnel ?)

> svn commit -m "upgrading to 1.2.6"

> rake rails:freeze:gems
(in C:/developement/ruby/prophet/trunk/prophet)
Freezing to the gems for Rails 1.2.6
rake aborted!
uninitialized constant Gem::GemRunner

(See full trace by running task with --trace)


>gem update --system
...

ATTENTION HACK
Supprimer le rep 'rails' dans 'vendor' à la main pour revenir à zéro...
Il y a un probleme de compatibilité entre les dernières version de rubygems et rails 1.2.6
Il faut ajouter 'require 'rubygems/gem_runner' dans C:\ruby\lib\ruby\gems\1.8\gems\rails-1.2.6\lib\tasks\framework.rake
cf: rubygems-095-and-rails-126-uninitialized-constant-gemgemrunner
> gem list rails

*** LOCAL GEMS ***

rails (2.0.2, 1.2.6)

ATTENTION
Bien préciser la version sinon ça va freezer la plus récente (ici on veut 1.2.6 pas la 2.0.2)
> rake rails:freeze:gems VERSION=1.2.6

Maintenant ça devrait marcher...

> svn add vendor/rails

> svn commit -m "freezing to 1.2.6"

Et voilà !
Plus vous avez de tests moins il y aura de régressions ;)
Passez un peu partout dans l'appli pour plus de sureté aussi, on est jamais trop prudent ;)

Aucun commentaire: