module AutoMigrations

Public Class Methods

run() click to toggle source
# File lib/data_plan/generators/migration/lib/auto_migrations.rb, line 3
def self.run
  # Turn off schema_info code for auto-migration
  class << ActiveRecord::Schema
    alias :old_define :define
    def define(info={}, &block) instance_eval(&block) end
  end

  load(File.join(DB_PROJECT_ROOT, 'db', 'plan.rb'))
  ActiveRecord::Migration.drop_unused_tables
  ActiveRecord::Migration.drop_unused_views
  ActiveRecord::Migration.drop_unused_indexes

  class << ActiveRecord::Schema
    alias :define :old_define
  end
end
schema_to_migration() click to toggle source
# File lib/data_plan/generators/migration/lib/auto_migrations.rb, line 20
def self.schema_to_migration
  schema = File.read(File.join(DB_PROJECT_ROOT, "db", "plan.rb")) rescue begin
    puts "Please copy your schema.rb file to plan.rb before generating migrations!"
    raise
  end