mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
*SVN*
|
||||
|
||||
* Added dump of schema version to the db_structure_dump task for databases that support migrations #1835 [Rick Olson]
|
||||
|
||||
* Fixed script/profiler for Ruby 1.8.2 #1863 [Rick Olson]
|
||||
|
||||
* Fixed clone_structure_to_test task for SQLite #1864 [jon@burningbush.us]
|
||||
|
||||
@@ -61,6 +61,10 @@ task :db_structure_dump => :environment do
|
||||
else
|
||||
raise "Unknown database adapter '#{abcs["test"]["adapter"]}'"
|
||||
end
|
||||
|
||||
if ActiveRecord::Base.connection.supports_migrations?
|
||||
File.open("db/#{RAILS_ENV}_structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information }
|
||||
end
|
||||
end
|
||||
|
||||
desc "Empty the test database"
|
||||
|
||||
Reference in New Issue
Block a user