aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2012-01-11 15:24:15 -0800
committerAaron Patterson <aaron.patterson@gmail.com>2012-01-13 14:33:54 -0800
commit67fba0cfa93feaa183d546de625e63cb16c56d7d (patch)
tree5c84bfbbe6749792410c0a7f5cd480468b53b0ba
parenta85625dacfe7782148f7566c199d562c8acb71c0 (diff)
downloadrails-67fba0cfa93feaa183d546de625e63cb16c56d7d.tar.gz
rails-67fba0cfa93feaa183d546de625e63cb16c56d7d.tar.bz2
rails-67fba0cfa93feaa183d546de625e63cb16c56d7d.zip
add a migration schema model
-rw-r--r--activerecord/lib/active_record/migration.rb6
-rw-r--r--activerecord/lib/active_record/schema_migration.rb9
2 files changed, 12 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb
index 8dade3b576..0a7a558675 100644
--- a/activerecord/lib/active_record/migration.rb
+++ b/activerecord/lib/active_record/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 @@ module ActiveRecord
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
diff --git a/activerecord/lib/active_record/schema_migration.rb b/activerecord/lib/active_record/schema_migration.rb
new file mode 100644
index 0000000000..5a04660dc3
--- /dev/null
+++ b/activerecord/lib/active_record/schema_migration.rb
@@ -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