Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 1095 Bytes
1 | class IntegerColumnsToBoolean < ActiveRecord::Migration |
2 | |
3 | class User < ActiveRecord::Base; end |
4 | |
5 | def self.up |
6 | change_column "users", "admin", :boolean, :default => false, :null => false |
7 | change_column "users", "developer", :boolean, :default => false, :null => false |
8 | end |
9 | |
10 | def self.down |
11 | change_column "users", "admin", :integer, :limit => 1, :default => 0, :null => false |
12 | change_column "users", "developer", :integer, :limit => 1, :default => 0, :null => false |
13 | end |
14 | |
15 | def self.change_column(table, column, type, options={}) |
16 | model_class = table.singularize.camelize.constantize |
17 | |
18 | announce "saving #{model_class} data" |
19 | old_values = model_class.find(:all).map do |model| |
20 | [model.id, model.send("#{column}?")] |
21 | end |
22 | |
23 | remove_column table, column |
24 | add_column table, column, type, options |
25 | |
26 | model_class.reset_column_information |
27 | |
28 | announce "restoring #{model_class} data" |
29 | old_values.each do |(id, value)| |
30 | model = model_class.find(id) |
31 | model.send "#{column}=", value |
32 | model.save |
33 | end |
34 | end |
35 | |
36 | end |