Created
April 30, 2013 02:07
-
-
Save aperley/5486207 to your computer and use it in GitHub Desktop.
Writes the migration to change all db string columns to text.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveRecord | |
class Schema | |
def self.define(options, &block) | |
instance_eval(&block) | |
end | |
def self.create_table(name, opts, &block) | |
yield StringLogger.new name | |
end | |
def self.method_missing(method, *args, &block) | |
# We don't care | |
end | |
end | |
class StringLogger | |
attr_accessor :table_name | |
def initialize(table_name) | |
@table_name = table_name | |
end | |
def string(name, opts={}) | |
puts "change_column :#{@table_name}, :#{name}, :text" | |
end | |
def method_missing(method, *args, &block) | |
# We don't care | |
end | |
end | |
end |
No, nothing fancy like that. This just knows enough to interpret the DSL in schema.rb
the way we want. You would just cut and paste the schema at the end of the file (or load
it) and then run it with plain Ruby.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would you just load this as a new initializer and then just run
rake db:create
?