|
| 1 | +class ConvertStringColumnsToText < ActiveRecord::Migration |
| 2 | + def self.up |
| 3 | + change_column :proposals, :description, :text |
| 4 | + change_column :schedule_items, :excerpt, :text |
| 5 | + change_column :schedule_items, :description, :text |
| 6 | + change_column :snippets, :description, :text |
| 7 | + change_column :tracks, :description, :text |
| 8 | + end |
| 9 | + |
| 10 | + def self.down |
| 11 | + change_column :proposals, :description, :string |
| 12 | + change_column :schedule_items, :excerpt, :string |
| 13 | + change_column :schedule_items, :description, :string |
| 14 | + change_column :snippets, :description, :string |
| 15 | + change_column :tracks, :description, :string |
| 16 | + end |
| 17 | +end |
| 18 | + |
| 19 | +__END__ |
| 20 | + |
| 21 | +# Add to database.yml |
| 22 | +old: |
| 23 | + adapter: sqlite3 |
| 24 | + timeout: 5000 |
| 25 | + database: db/development.sqlite3 |
| 26 | + |
| 27 | +class OldProposal < Proposal |
| 28 | + establish_connection "old" |
| 29 | +end |
| 30 | +OldProposal.all.each do |old| |
| 31 | + current = Proposal.find(old.id) |
| 32 | + current.description = old.description |
| 33 | + current.save! |
| 34 | +end |
| 35 | + |
| 36 | +class OldScheduleItem < ScheduleItem |
| 37 | + establish_connection "old" |
| 38 | +end |
| 39 | +OldScheduleItem.all.each do |old| |
| 40 | + current = ScheduleItem.find(old.id) |
| 41 | + current.description = old.description |
| 42 | + current.excerpt = old.excerpt |
| 43 | + current.save! |
| 44 | +end |
| 45 | + |
| 46 | +class OldSnippet < Snippet |
| 47 | + establish_connection "old" |
| 48 | +end |
| 49 | +OldSnippet.all.each do |old| |
| 50 | + current = Snippet.find(old.id) |
| 51 | + current.description = old.description |
| 52 | + current.save! |
| 53 | +end |
| 54 | + |
| 55 | +class OldTrack < Track |
| 56 | + establish_connection "old" |
| 57 | +end |
| 58 | +OldTrack.all.each do |old| |
| 59 | + current = Track.find(old.id) |
| 60 | + current.description = old.description |
| 61 | + current.save! |
| 62 | +end |
| 63 | + |
0 commit comments