Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rake db:migrate fails if tables is not exist #8

Open
CJRoman opened this issue Jan 20, 2014 · 4 comments
Open

rake db:migrate fails if tables is not exist #8

CJRoman opened this issue Jan 20, 2014 · 4 comments

Comments

@CJRoman
Copy link

CJRoman commented Jan 20, 2014

rake db:migrate fails when there is no database created yet. For example:

class User:

class User < ActiveRecord::Base
...
acts_as_xlsx
end

and rake db:migrate shows this:

roman@roman-home:~/tgmu_rating$ rake db:migrate
rake aborted!
Could not find table 'users'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:509:in table_structure' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/sqlite3_adapter.rb:396:incolumns'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/schema_cache.rb:114:in block in prepare_default_proc' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/schema_cache.rb:56:inyield'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/schema_cache.rb:56:in columns' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/model_schema.rb:208:incolumns'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/model_schema.rb:247:in column_names' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/acts_as_xlsx-1.0.6/lib/acts_as_xlsx/ar.rb:31:inacts_as_xlsx'
/home/roman/tgmu_rating/app/models/user.rb:18:in <class:User>' /home/roman/tgmu_rating/app/models/user.rb:1:in<top (required)>'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:in load' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:423:inblock in load_file'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:615:in new_constants_in' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:422:inload_file'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:323:in require_or_load' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:462:inload_missing_constant'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:183:in const_missing' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:226:inconst_get'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:226:in block in constantize' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:ineach'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:in inject' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/inflector/methods.rb:224:inconstantize'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:534:in get' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:565:inconstantize'
/home/roman/.rvm/gems/ruby-2.0.0-p353/bundler/gems/devise-d5e0171cb407/lib/devise.rb:297:in get' /home/roman/.rvm/gems/ruby-2.0.0-p353/bundler/gems/devise-d5e0171cb407/lib/devise/mapping.rb:77:into'
/home/roman/.rvm/gems/ruby-2.0.0-p353/bundler/gems/devise-d5e0171cb407/lib/devise/mapping.rb:72:in modules' /home/roman/.rvm/gems/ruby-2.0.0-p353/bundler/gems/devise-d5e0171cb407/lib/devise/mapping.rb:89:inroutes'
/home/roman/.rvm/gems/ruby-2.0.0-p353/bundler/gems/devise-d5e0171cb407/lib/devise/mapping.rb:156:in default_used_route' /home/roman/.rvm/gems/ruby-2.0.0-p353/bundler/gems/devise-d5e0171cb407/lib/devise/mapping.rb:66:ininitialize'
/home/roman/.rvm/gems/ruby-2.0.0-p353/bundler/gems/devise-d5e0171cb407/lib/devise.rb:331:in new' /home/roman/.rvm/gems/ruby-2.0.0-p353/bundler/gems/devise-d5e0171cb407/lib/devise.rb:331:inadd_mapping'
/home/roman/.rvm/gems/ruby-2.0.0-p353/bundler/gems/devise-d5e0171cb407/lib/devise/rails/routes.rb:221:in block in devise_for' /home/roman/.rvm/gems/ruby-2.0.0-p353/bundler/gems/devise-d5e0171cb407/lib/devise/rails/routes.rb:220:ineach'
/home/roman/.rvm/gems/ruby-2.0.0-p353/bundler/gems/devise-d5e0171cb407/lib/devise/rails/routes.rb:220:in devise_for' /home/roman/tgmu_rating/config/routes.rb:12:inblock in <top (required)>'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:316:in instance_exec' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:316:ineval_block'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:294:in draw' /home/roman/tgmu_rating/config/routes.rb:1:in<top (required)>'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:in load' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:inblock in load'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in load_dependency' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:222:inload'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:40:in block in load_paths' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:40:ineach'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:40:in load_paths' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/application/routes_reloader.rb:16:inreload!'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/application.rb:102:in reload_routes!' /home/roman/.rvm/gems/ruby-2.0.0-p353/bundler/gems/active_admin-f21cff30e721/lib/active_admin/application.rb:239:inblock in attach_reloader'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:387:in _run__571715648900980799__prepare__callbacks' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:inrun_callbacks'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.0/lib/action_dispatch/middleware/reloader.rb:74:in prepare!' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/actionpack-4.0.0/lib/action_dispatch/middleware/reloader.rb:46:inprepare!'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/application/finisher.rb:50:in block in <module:Finisher>' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/initializable.rb:30:ininstance_exec'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/initializable.rb:30:in run' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/initializable.rb:55:inblock in run_initializers'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/initializable.rb:54:in run_initializers' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/application.rb:215:ininitialize!'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/railtie/configurable.rb:30:in method_missing' /home/roman/tgmu_rating/config/environment.rb:6:in<top (required)>'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:in require' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:inblock in require'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:213:in load_dependency' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/activesupport-4.0.0/lib/active_support/dependencies.rb:228:inrequire'
/home/roman/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/application.rb:189:in require_environment!' /home/roman/.rvm/gems/ruby-2.0.0-p353/gems/railties-4.0.0/lib/rails/application.rb:249:inblock in run_tasks_blocks'
Tasks: TOP => db:migrate => environment
(See full trace by running task with --trace)

Was fixed with that:

class User < ActiveRecord::Base
...
acts_as_xlsx if ActiveRecord::Base.connection.table_exists? 'users'
end

But I think it is not "Rails way"

@matiaskorhonen
Copy link

This is fixes in master (f57f64f), perhaps a new RubyGems release would be in order…

@darrenterhune
Copy link

New gem release would be nice @randym 👍

@MaicolBen
Copy link

Is it fixed in the 1.0.6 gem version ? I've the same problem with only active admin classes.

@agordillo
Copy link

I confirm that this bug remains in the 1.0.6 version.

I fixed it changing my gemfile in the following way:

gem 'acts_as_xlsx', '= 1.0.6'
=>
gem 'acts_as_xlsx', :git => '[email protected]:randym/acts_as_xlsx.git', :ref => '919817e590b1cf8e27632e630469603c78a50402'

+1 to a new gem release @randym

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants