diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-12 05:33:18 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2005-09-12 05:33:18 +0000 |
commit | a16528f715f49531c6013dde741fcba8182202b6 (patch) | |
tree | 6662c2a59e0793e2f9c606baa967ef2b66fdafb8 /activerecord | |
parent | 9105cd10640c06b53536d99211ef8183b1fa7705 (diff) | |
download | rails-a16528f715f49531c6013dde741fcba8182202b6.tar.gz rails-a16528f715f49531c6013dde741fcba8182202b6.tar.bz2 rails-a16528f715f49531c6013dde741fcba8182202b6.zip |
Added dump of schema version to the db_structure_dump task for databases that support migrations #1835 [Rick Olson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2215 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | 12 | ||||
-rw-r--r-- | activerecord/lib/active_record/migration.rb | 2 |
2 files changed, 12 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index e0c880780e..cbc8e7c273 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -374,7 +374,17 @@ module ActiveRecord # Schema has been intialized end end - + + def dump_schema_information + begin + if (current_schema = ActiveRecord::Migrator.current_version) > 0 + return "INSERT INTO schema_info (version) VALUES (#{current_schema});" + end + rescue ActiveRecord::StatementInvalid + # No Schema Info + end + end + def create_table(name, options = {}) table_definition = TableDefinition.new(self) table_definition.primary_key(options[:primary_key] || "id") unless options[:id] == false diff --git a/activerecord/lib/active_record/migration.rb b/activerecord/lib/active_record/migration.rb index 6f9b0ee2b4..9cde37548d 100644 --- a/activerecord/lib/active_record/migration.rb +++ b/activerecord/lib/active_record/migration.rb @@ -170,7 +170,7 @@ module ActiveRecord end def current_version - Base.connection.select_one("SELECT version FROM schema_info")["version"].to_i + (Base.connection.select_one("SELECT version FROM schema_info") || {})["version"].to_i end end |