a guest Aug 11th, 2018 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- # I have a project. Migrations are stored in lib/foo/schema/xxx_description.rb,
- # with classes called Foo::Schema::Description.
- class Foo::Schema
- # Pretty simple, just tell AR to migrate based on my stored migrations
- def self.up
- ActiveRecord::Base.logger ||= Logger.new(StringIO.new)
- def self.migrations_path
- File.expand_path('../schema', __FILE__)
- # Oh, but to make AR happy, the migration class names need to exist in the
- # global namespace, so I need to load my migrations and export all the
- # constants in Foo::Schema into the global namespace.
- Dir.entries(migrations_path).each do |file|
- path = File.join(migrations_path, file)
- require path if File.file?(path)
- constants.each do |const_name|
- Kernel.const_set(const_name, const_get(const_name))
RAW Paste Data