This project is archived and is in readonly mode.
freeze gems - supports_migrations? breaks schema_format = :sql
Reported by Doug Sparling | February 10th, 2009 @ 07:28 PM | in 3.x
Environment: Mac OS X 10.5 Rails 2.2.2 (moving up from 2.0.2 - the few deprecated items have been removed).
When moving to Rails 2.2.2 I decided to freeze gems. It was after the freeze that I started having trouble generating my test database structure from a legacy database (no migrations).
I have uncommented
"config.active_record.schema_format = :sql"
in config/environment.rb
What's basically happening is that the db/development_structure.sql is getting built (when running rake db:test:clone_structure) but then it dies with an error because it is trying to use a non-existent schema.rb to build the test database instead of development_structure.sql.
When I run "rake db:test:clone_structure"
Macintosh:trunk dsparlingimbp$ rake db:structure:dump --trace
(in /Users/dsparlingimbp/Sites/webservice_reg/trunk) Invoke
db:structure:dump (first_time) Invoke environment
(first_time) Execute environment Execute
db:structure:dump rake aborted! Mysql::Error: Table
'uclick_test.schema_migrations' doesn't exist: SELECT version FROM
schema_migrations
/Users/dsparlingimbp/Sites/webservice_reg/trunk/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb:188:in
log'
/Users/dsparlingimbp/Sites/webservice_reg/trunk/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:309:in
execute'
/Users/dsparlingimbp/Sites/webservice_reg/trunk/vendor/rails/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb:301:in
select_rows'
/Users/dsparlingimbp/Sites/webservice_reg/trunk/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:27:in
select_values'
/Users/dsparlingimbp/Sites/webservice_reg/trunk/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb:310:in
dump_schema_information'
/Users/dsparlingimbp/Sites/webservice_reg/trunk/vendor/rails/railties/lib/tasks/databases.rake:288
/Users/dsparlingimbp/Sites/webservice_reg/trunk/vendor/rails/railties/lib/tasks/databases.rake:288:in
open'
/Users/dsparlingimbp/Sites/webservice_reg/trunk/vendor/rails/railties/lib/tasks/databases.rake:288
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in
call'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in
execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in
each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in
execute'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in
invoke_with_call_chain'
/usr/local/lib/ruby/1.8/monitor.rb:238:in
synchronize'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in
invoke_with_call_chain'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in
invoke'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in
invoke_task'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in
top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in
each'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in
top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in
standard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in
top_level'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in
run'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in
standard_exception_handling'
/usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in
run' /usr/local/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31
/usr/local/bin/rake:19:in
load' /usr/local/bin/rake:19
Running rake db:test:load (development_structure.sql did get built):
Macintosh:trunk dsparlingimbp$ rake db:test:load (in /Users/dsparlingimbp/Sites/webservice_reg/trunk) rake aborted! no such file to load -- /Users/dsparlingimbp/Sites/webservice_reg/trunk/db/schema.rb
So it looks like it's trying to find schema.rb even though I've set schema_format to sql.
To get by, I commented out:
#if ActiveRecord::Base.connection.supports_migrations?
# File.open("#{RAILS_ROOT}/db/#{RAILS_ENV}_structure.sql", "a") { |f| f << ActiveRecord::Base.connection.dump_schema_information }
#end
in vendor/rails/railties/lib/tasks/databases.rake
I'm using mysql - "supports_migrations?" is set to true in vendor/rails/activerecord/lib/active_record/connection_adapter/mysql_adapter.rb
def supports_migrations? #:nodoc: true end
Since it assumes supports_migrations? is true based on the fact I'm using mysql, then dump_schema_information is called:
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
def dump_schema_information #:nodoc:
sm_table = ActiveRecord::Migrator.schema_migrations_table_name
migrated = select_values("SELECT version FROM #{sm_table}")
migrated.map { |v| "INSERT INTO #{sm_table} (version) VALUES ('#{v}');" }.join("\n\n")
end
and here's what causes my error:
migrated = select_values("SELECT version FROM #{sm_table}")
Not sure if this is a bug, or something I've done wrong...it's only after freezing Rails that I had the problem.
Thanks,
doug sparling
Comments and changes to this ticket
-
Santiago Pastorino February 2nd, 2011 @ 04:41 PM
- State changed from new to open
- Importance changed from to
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
Santiago Pastorino February 2nd, 2011 @ 04:41 PM
- State changed from open to stale
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>