rgeo / activerecord-mysql2spatial-adapter

ActiveRecord connection adapter for MySQL Spatial Extensions, based on mysql2 and rgeo
48 stars 64 forks source link

Spatial Migrations Not Working For Me #1

Closed gordonbanderson closed 13 years ago

gordonbanderson commented 13 years ago

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:inmethod_missing' /Users/gordon/work/git/weboftalent/rgeoexamplapp/rgeo-example/db/migrate/20110208022206_create_photographs.rb:5:in up_without_benchmarks' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/connection_adapters/abstract/schema_statements.rb:157:increate_table' /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/active_record/connection_adapters/mysql2_adapter.rb:470:in create_table' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:383:insend' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:383:in method_missing' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:359:insay_with_time' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in measure' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:359:insay_with_time' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:379:in method_missing' /Users/gordon/work/git/weboftalent/rgeoexamplapp/rgeo-example/db/migrate/20110208022206_create_photographs.rb:3:inup_without_benchmarks' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:312:in send' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:312:inmigrate' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/benchmark.rb:293:in measure' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:312:inmigrate' /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:inmigrate' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:537:in migrate' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:613:incall' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:613:in ddl_transaction' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:536:inmigrate' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:523:in each' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:523:inmigrate' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:433:in up' /Library/Ruby/Gems/1.8/gems/activerecord-3.0.3/lib/active_record/migration.rb:415:inmigrate' /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:in call' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:inexecute' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in each' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:inexecute' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in invoke_with_call_chain' /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/monitor.rb:242:insynchronize' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in invoke_with_call_chain' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:ininvoke' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in invoke_task' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in each' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:intop_level' /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:2023:intop_level' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in run' /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:1998:in run' /Library/Ruby/Gems/1.8/gems/rake-0.8.7/bin/rake:31 /usr/bin/rake:19:inload' /usr/bin/rake:19

It 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

dazuma commented 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"?

gordonbanderson commented 13 years ago

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

sridharraman commented 8 years ago

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?

januszm commented 8 years ago

@sridharraman please provide information about version of: Rails, mysql2spatial-adapter and Ruby (the latter might be irrelevant though)

sridharraman commented 8 years ago

rails (4.1.15) activerecord-mysql2spatial-adapter (0.4.3) ruby 2.2.1p85

januszm commented 8 years ago

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.

sridharraman commented 8 years ago

Thanks @januszm. That works.

januszm commented 8 years ago

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.