Closed gordonbanderson closed 13 years ago
Can you post your database.yml? (I see a database.yml.example in your github repo but not database.yml.) Have you set the adapter name to "mysql2spatial"?
hi Daniel
Thanks for the quick reply - nope, I had not changed database adapter as mentioned above as I had not realized I had to.... Rereading the home page for activerecord-mysql2spatial-adapter on github I can see the necessary information that I missed. My bad.
The migration is working, so feel free to close this issue. Thanks again for the prompt reply, appreciated
Gordon
Hi
I am facing the same problem. I am unable to run any spatial migration. I've tried geometry, multi_polygon. But I get the same error when I run rake db:migrate: undefined method `geometry' for #ActiveRecord::ConnectionAdapters::TableDefinition:0x0000000afdf480
I have set the adapter in the database.yml file to mysql2spatial as well. But nothing seems to work.
What could be the cause of this problem?
@sridharraman please provide information about version of: Rails, mysql2spatial-adapter and Ruby (the latter might be irrelevant though)
rails (4.1.15) activerecord-mysql2spatial-adapter (0.4.3) ruby 2.2.1p85
Use this one: https://rubygems.org/gems/activerecord-mysql2spatial-adapter/versions/0.5.0.nonrelease I've made this version for one of my production apps running on Rails 4.1, works fine.
That release doesn't support Rails 4.2 and 5 though.
Thanks @januszm. That works.
Unfortunately I don't have time to work on support for Rails 4.2 and 5.0 at the moment and I can't guarantee that it will happen anytime soon. Maybe later this year.
hi Daniel
I am having problems with getting spatial migrations to work with RGeo. It is of course possible I have misunderstood something simple but I have not seen a fully worked example with migrations on the web.
As such I have created a skeleton rails app with one model at https://github.com/gordonbanderson/RGeo-Migration-Example/
To recreate the issue I am having clone the repository, configure database.yml, execute bundle install. I then get the following error on running bundle exec rake db:migrate:
rgeo-example gordon$ bundle exec rake --trace db:migrate (in /Users/gordon/work/git/weboftalent/rgeoexamplapp/rgeo-example) * Invoke db:migrate (first_time) * Invoke environment (first_time) * Execute environment * Execute db:migrate == CreatePhotographs: migrating ============================================== -- create_table(:photographs, {:options=>"ENGINE=MyISAM"}) rake aborted! An error has occurred, all later migrations canceled:
undefined method
line_string' for #<ActiveRecord::ConnectionAdapters::TableDefinition:0x103aefa48> /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/schema_definitions.rb:326:in
method_missing' /Users/gordon/work/git/weboftalent/rgeoexamplapp/rgeo-example/db/migrate/20110208022206_create_photographs.rb:5:inup_without_benchmarks' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:157:in
create_table' /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:470:increate_table' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:383:in
send' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:383:inmethod_missing' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:359:in
say_with_time' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:inmeasure' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:359:in
say_with_time' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:379:inmethod_missing' /Users/gordon/work/git/weboftalent/rgeoexamplapp/rgeo-example/db/migrate/20110208022206_create_photographs.rb:3:in
up_without_benchmarks' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:312:insend' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:312:in
migrate' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:inmeasure' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:312:in
migrate' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:395:in__send__' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:395:in
migrate' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:537:inmigrate' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:613:in
call' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:613:inddl_transaction' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:536:in
migrate' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:523:ineach' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:523:in
migrate' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:433:inup' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:415:in
migrate' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/railties/databases.rake:142 /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:incall' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in
execute' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:ineach' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in
execute' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:ininvoke_with_call_chain' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:in
synchronize' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_chain' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in
invoke' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:ininvoke_task' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:ineach' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in
top_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:inrun' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
standard_exception_handling' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:inrun' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31 /usr/bin/rake:19:in
load' /usr/bin/rake:19It looks to me that the extensions to active record with regards to migrations are not being picked up for some reason. Have I included the right gems, or is there some other configuration that I am missing?
Regards
Gordon