Skip to content

Instantly share code, notes, and snippets.

@aperley
Created April 30, 2013 02:07
Show Gist options
  • Save aperley/5486207 to your computer and use it in GitHub Desktop.
Save aperley/5486207 to your computer and use it in GitHub Desktop.
Writes the migration to change all db string columns to text.
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
@aperley
Copy link
Author

aperley commented Apr 30, 2013

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