From 97a35e280b4e27e5508d79dae93ae1a94c8183be Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Wed, 21 Oct 2009 00:42:48 -0500 Subject: [PATCH] DB Migration % rake upgrade_instiki fixes some potential problems in the database column types. Revision content can now be up to 16MB. Under MySQL, the previous limit was 64KB. Page names can now be up to 255 bytes. Under MySQL, the previous limit was 60 bytes. Additional CSS styles can now be up to 64KB. Under MySQL, the previous limit was 255 bytes. Thanks to Andrew Stacey for reporting these. --- .../20091021024908_modify_text_types.rb | 11 +++++ db/production.db.sqlite3 | Bin 19456 -> 21504 bytes lib/tasks/upgrade_instiki.rake | 43 ++++++++++++------ 3 files changed, 41 insertions(+), 13 deletions(-) create mode 100644 db/migrate/20091021024908_modify_text_types.rb diff --git a/db/migrate/20091021024908_modify_text_types.rb b/db/migrate/20091021024908_modify_text_types.rb new file mode 100644 index 00000000..04ede3f4 --- /dev/null +++ b/db/migrate/20091021024908_modify_text_types.rb @@ -0,0 +1,11 @@ +class ModifyTextTypes < ActiveRecord::Migration + def self.up + change_column :revisions, :content, :text, :limit => 16777215 + change_column :pages, :name, :string, :limit => 255 + change_column :webs, :additional_style, :text + end + + def self.down + raise ActiveRecord::IrreversibleMigration + end +end diff --git a/db/production.db.sqlite3 b/db/production.db.sqlite3 index 4ac372fe17df5fd159b2db9fa9619f67f423c943..4018a127a84e772cb8d1f9c097f75192feffb090 100644 GIT binary patch delta 1410 zcmbtUTTc@~6yDis*;3o|0%Z%ObXj8TZX0QYt-9Sq(%Ox=c zsu<;gD9nq0z(k*n)&~=VzM1&olZmf}$WJh8BvEHuZlw|vn9Q8XoZFo9oinrW7%V&m zk6bpEsva#b{2yRP6JZ)`gfJ$fCf8|%GLvN@OJnIuHr-cP+GOgjPCeC1k%_^3`X2q8 z2)71aa?O-Jww(ev?0Z-GDcuHk&4r#?qNpX%1m4gm>DMd8aXi;*!iD~2JS06C$ype- zvlA3;sysS@3W*d-%ki`_mX}p!GE=BwG+w+eg<}#I3tt$JIKD>Cb6$QL2IBTJANiwI`-f~)Dw9mt0)#$E%Ot*2Qk)fatD@Prc%EfghXXuFlsk9^jTW?3SJkV$#yaR_ncOK{bUW%* zG^={G+LoTX+W;_@fC1`^5N=R#6Mlyqw2_TIwYD|nerrMQc4 zdQ|yBuEZE9MOYGr1j|59IdU4Lq(3D1Cr%~f0(Z=D$Ds2jIXE1CzF&ukJU0iHZ>@Ey z*Rtt`)pUC6{fUxayjwL_s@jTqt6tS6KD6RCbv>uw)1019JJdDybG#_aGCY$J%6YPB zb?~QRde?-a|} z%-+OxwSl9nm+^;sE{u*v&L%#pr7wk@fjMO-9@^!(0mlvauZP1e9OU9T=4pqnd0|8@ zxL^qWQabpsW{2Cz(P zGlfZN%cYi2+fB>Yjeb;=Z!mV^eDqOi2CtWN)q3LFeOK3RFKd&+F>GL=XyZcW-usH6 iux%S0{N=ZZ2aVBi5ip%U3Z7?n0S|I7AQpghM*ag=z^#M; diff --git a/lib/tasks/upgrade_instiki.rake b/lib/tasks/upgrade_instiki.rake index ef242c42..35b66954 100644 --- a/lib/tasks/upgrade_instiki.rake +++ b/lib/tasks/upgrade_instiki.rake @@ -1,17 +1,34 @@ -task :upgrade_instiki => :environment do - RAILS_ENV = 'production' unless ENV['RAILS_ENV'] - puts "Upgrading Instiki in #{RAILS_ENV} environment." +require 'rake' - Web.all.each do |web| - public_path = Rails.root.join("public", web.address) - if public_path.exist? - webs_path = Rails.root.join("webs", web.address) - if webs_path.exist? - puts "Warning! The directory #{webs_path} already exists. Skipping." - else - public_path.rename(webs_path) - puts "Moved #{public_path} to #{webs_path}" +desc "This task will perform necessary upgrades to your Instiki installation" +task :upgrade_instiki => :environment do + ENV['RAILS_ENV'] ||= 'production' + puts "Upgrading Instiki in #{ENV['RAILS_ENV']} environment." + + InstikiUpgrade.migrate_db + InstikiUpgrade.move_uploaded_files +end + +class InstikiUpgrade + + def self.migrate_db + ActiveRecord::Base.establish_connection ENV['RAILS_ENV'] + Rake::Task["db:migrate"].invoke + end + + def self.move_uploaded_files + Web.all.each do |web| + public_path = Rails.root.join("public", web.address) + if public_path.exist? + webs_path = Rails.root.join("webs", web.address) + if webs_path.exist? + puts "Warning! The directory #{webs_path} already exists. Skipping." + else + public_path.rename(webs_path) + puts "Moved #{public_path} to #{webs_path}" + end end end end -end + +end \ No newline at end of file