projectblacklight / blacklight

Blacklight provides a discovery interface for any Solr (http://lucene.apache.org/solr) index.
http://projectblacklight.org/
Other
758 stars 257 forks source link

Missing db tables #1766

Closed kunwon1 closed 7 years ago

kunwon1 commented 7 years ago

Hello

tl;dr how can I recreate the sqlite3 database as it 'should be'? I am missing tables

I posted a question about this to the dev mailing list, but it seems to have vanished :( sorry for double posting if I'm missing something

I followed the quick start 'the hard way' and got blacklight partially working, I have a pre-existing solr 4.x instance and nutch pushing data into it.

I can render the search page, when i perform a query I get an error about missing db table. I believe it was the 'bookmarks' table. Based on one of the migrations that exists in the git repo (and not in my local blacklight instance, for some reason) i was able to add a table to the sqlite3 db that allows me to do searches and see results. However when I try to click on a result I get a new error about missing table, and I do not believe my tables are 100% correct, I do not know the idioms ActiveRecord, I believe it creates other tables that I am not seeing

I am 100% sure I performed the rake task to create/migrate the DB

How can I fix this database?

jkeck commented 7 years ago

Which files are in your application's db/migrate folder?

kunwon1 commented 7 years ago

20170829202902_devise_create_users.rb and 20170829202905_add_devise_guests_to_users.rb

Nothing else

jkeck commented 7 years ago

It seems like the some part of the blacklight installation process must have not run or completed properly. When running rails generate blacklight:install ... the blacklight:install:migrations rake task should have been run, which would install all the database migrations the Blacklight requires into your application.

Did any errors pop-up when running rails generate blacklight:install ...?

kunwon1 commented 7 years ago

I do not recall with 100% certainty if there were any errors

I just ran it again, and I still do not have correct migrations

output attached

output.txt

jkeck commented 7 years ago

It looks like devise is choking on that 2nd run (most likely didn't happen on your first, as it is about duplicate routes).

Are you able to re-run in the installation from the beginning? (e.g. clear out files that were created).

If not, I would recommend running the rake task rake blacklight:install:migrations and run rake db:migrate again (assuming that task properly copies the migrations up to your db/migrate folder.

You may run into more issues w/ installation steps further down the line that did not execute correctly, so if you can ensure a clean install from the beginning, you might be in a better situation.

kunwon1 commented 7 years ago

I re-ran the installation from the beginning, and I found the error, I don't know how I missed it the first time

Debian 9 / stretch

NoMethodError: undefined method `[]' for #<ActiveRecord::Migration:0x005638a0965508>

full output follows

root@search:/searchengine# ruby --version
ruby 2.3.3p222 (2016-11-21) [x86_64-linux-gnu]

root@search:/searchengine# rails --version
Rails 4.2.7.1

root@search:/searchengine# java -version
openjdk version "1.8.0_141"
OpenJDK Runtime Environment (build 1.8.0_141-8u141-b15-1~deb9u1-b15)
OpenJDK 64-Bit Server VM (build 25.141-b15, mixed mode)

rails new rails_search_webapp
cd rails_search_webapp
echo "gem 'blacklight', \">= 6.1\"" >> Gemfile
echo "gem 'therubyracer'" >> Gemfile
rails generate blacklight:install --devise --solr_version=4
rake db:migrate

root@search:/searchengine/rails_search_webapp# rake db:migrate
-- [](4.2)
-- [](4.2)
rake aborted!
NoMethodError: undefined method `[]' for #<ActiveRecord::Migration:0x005638a0965508>
/searchengine/rails_search_webapp/db/migrate/20171003005340_create_searches.blacklight.rb:3:in `<top (required)>'
/var/lib/gems/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
NoMethodError: undefined method `[]' for #<ActiveRecord::Migration:0x005638a0965508>
/searchengine/rails_search_webapp/db/migrate/20171003005340_create_searches.blacklight.rb:3:in `<top (required)>'
/var/lib/gems/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

root@search:/searchengine/rails_search_webapp# rake db:migrate --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:migrate
-- [](4.2)
-- [](4.2)
rake aborted!
NoMethodError: undefined method `[]' for #<ActiveRecord::Migration:0x0055d01cbdcee0>
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:664:in `block in method_missing'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:634:in `block in say_with_time'
/usr/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:634:in `say_with_time'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:654:in `method_missing'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:416:in `method_missing'
/searchengine/rails_search_webapp/db/migrate/20171003005340_create_searches.blacklight.rb:3:in `<top (required)>'
/usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:274:in `require'
/usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:274:in `block in require'
/usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:240:in `load_dependency'
/usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:274:in `require'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:777:in `load_migration'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:773:in `migration'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:768:in `disable_ddl_transaction'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:1051:in `use_transaction?'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:961:in `rescue in block in migrate'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:958:in `block in migrate'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:955:in `each'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:955:in `migrate'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:823:in `up'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:801:in `migrate'
/usr/lib/ruby/vendor_ruby/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/lib/ruby/vendor_ruby/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/usr/lib/ruby/vendor_ruby/rake/task.rb:240:in `block in execute'
/usr/lib/ruby/vendor_ruby/rake/task.rb:235:in `each'
/usr/lib/ruby/vendor_ruby/rake/task.rb:235:in `execute'
/usr/lib/ruby/vendor_ruby/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/usr/lib/ruby/vendor_ruby/rake/task.rb:172:in `invoke_with_call_chain'
/usr/lib/ruby/vendor_ruby/rake/task.rb:165:in `invoke'
/usr/lib/ruby/vendor_ruby/rake/application.rb:150:in `invoke_task'
/usr/lib/ruby/vendor_ruby/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/lib/ruby/vendor_ruby/rake/application.rb:106:in `each'
/usr/lib/ruby/vendor_ruby/rake/application.rb:106:in `block in top_level'
/usr/lib/ruby/vendor_ruby/rake/application.rb:115:in `run_with_threads'
/usr/lib/ruby/vendor_ruby/rake/application.rb:100:in `top_level'
/usr/lib/ruby/vendor_ruby/rake/application.rb:78:in `block in run'
/usr/lib/ruby/vendor_ruby/rake/application.rb:176:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:75:in `run'
/var/lib/gems/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/usr/local/bin/rake:22:in `load'
/usr/local/bin/rake:22:in `<main>'
NoMethodError: undefined method `[]' for #<ActiveRecord::Migration:0x0055d01cbdcee0>
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:664:in `block in method_missing'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:634:in `block in say_with_time'
/usr/lib/ruby/2.3.0/benchmark.rb:293:in `measure'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:634:in `say_with_time'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:654:in `method_missing'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:416:in `method_missing'
/searchengine/rails_search_webapp/db/migrate/20171003005340_create_searches.blacklight.rb:3:in `<top (required)>'
/usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:274:in `require'
/usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:274:in `block in require'
/usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:240:in `load_dependency'
/usr/lib/ruby/vendor_ruby/active_support/dependencies.rb:274:in `require'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:777:in `load_migration'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:773:in `migration'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:768:in `disable_ddl_transaction'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:1051:in `use_transaction?'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:1043:in `ddl_transaction'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:997:in `execute_migration_in_transaction'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:959:in `block in migrate'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:955:in `each'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:955:in `migrate'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:823:in `up'
/usr/lib/ruby/vendor_ruby/active_record/migration.rb:801:in `migrate'
/usr/lib/ruby/vendor_ruby/active_record/tasks/database_tasks.rb:137:in `migrate'
/usr/lib/ruby/vendor_ruby/active_record/railties/databases.rake:44:in `block (2 levels) in <top (required)>'
/usr/lib/ruby/vendor_ruby/rake/task.rb:240:in `block in execute'
/usr/lib/ruby/vendor_ruby/rake/task.rb:235:in `each'
/usr/lib/ruby/vendor_ruby/rake/task.rb:235:in `execute'
/usr/lib/ruby/vendor_ruby/rake/task.rb:179:in `block in invoke_with_call_chain'
/usr/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/usr/lib/ruby/vendor_ruby/rake/task.rb:172:in `invoke_with_call_chain'
/usr/lib/ruby/vendor_ruby/rake/task.rb:165:in `invoke'
/usr/lib/ruby/vendor_ruby/rake/application.rb:150:in `invoke_task'
/usr/lib/ruby/vendor_ruby/rake/application.rb:106:in `block (2 levels) in top_level'
/usr/lib/ruby/vendor_ruby/rake/application.rb:106:in `each'
/usr/lib/ruby/vendor_ruby/rake/application.rb:106:in `block in top_level'
/usr/lib/ruby/vendor_ruby/rake/application.rb:115:in `run_with_threads'
/usr/lib/ruby/vendor_ruby/rake/application.rb:100:in `top_level'
/usr/lib/ruby/vendor_ruby/rake/application.rb:78:in `block in run'
/usr/lib/ruby/vendor_ruby/rake/application.rb:176:in `standard_exception_handling'
/usr/lib/ruby/vendor_ruby/rake/application.rb:75:in `run'
/var/lib/gems/2.3.0/gems/rake-12.0.0/exe/rake:27:in `<top (required)>'
/usr/local/bin/rake:22:in `load'
/usr/local/bin/rake:22:in `<main>'
Tasks: TOP => db:migrate
jcoyne commented 7 years ago

It looks like you are trying to install Blacklight under Rails 4.2, which is obsolete (See http://guides.rubyonrails.org/maintenance_policy.html). Blacklight currently only supports Rails 5.0+ Can you upgrade to Rails 5.1.4?

kunwon1 commented 7 years ago

Yes, I think that fixes everything. I am getting an error when i click on search results, but I believe this is because I need to do further customization to match my solr

it's worth noting that the quickstart says 'Blacklight works with Rails 4.2'

jcoyne commented 7 years ago

it's worth noting that the quickstart says 'Blacklight works with Rails 4.2'

Thanks. I'll make sure to change that.