Permalink
Browse files

add a migration schema model

  • Loading branch information...
1 parent a85625d commit 67fba0cfa93feaa183d546de625e63cb16c56d7d @tenderlove tenderlove committed Jan 11, 2012
Showing with 12 additions and 3 deletions.
  1. +3 −3 activerecord/lib/active_record/migration.rb
  2. +9 −0 activerecord/lib/active_record/schema_migration.rb
@@ -1,6 +1,7 @@
require "active_support/core_ext/module/delegation"
require "active_support/core_ext/class/attribute_accessors"
require 'active_support/deprecation'
+require 'active_record/schema_migration'
module ActiveRecord
# Exception that can be raised to stop migrations from going backwards.
@@ -582,12 +583,11 @@ def open(migrations_paths)
end
def schema_migrations_table_name
- Base.table_name_prefix + 'schema_migrations' + Base.table_name_suffix
+ SchemaMigration.table_name
end
def get_all_versions
- table = Arel::Table.new(schema_migrations_table_name)
- Base.connection.select_values(table.project(table['version'])).map{ |v| v.to_i }.sort
+ SchemaMigration.all.map { |x| x.version.to_i }.sort
end
def current_version
@@ -0,0 +1,9 @@
+require 'active_record'
+
+module ActiveRecord
+ class SchemaMigration < ActiveRecord::Base
+ def self.table_name
+ Base.table_name_prefix + 'schema_migrations' + Base.table_name_suffix
+ end
+ end
+end

0 comments on commit 67fba0c

Please sign in to comment.