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 #1877

Closed
librarymark opened this issue Jan 10, 2018 · 9 comments
Closed

rake db:migrate fails #1877

librarymark opened this issue Jan 10, 2018 · 9 comments

Comments

@librarymark
Copy link

Total ruby/rails newbie here - I am trying to just take a quick look at spotlight. I am following the steps to install it, and I run this:
rails new spotlight -m https://raw.githubusercontent.com/projectblacklight/spotlight/master/template.rb
And it seems to finish fine. Then I do the next step,
rake db:migrate
(in the spotlight directory) and I get this:
DEPRECATION WARNING: Initializing a file resolver without setting the base path is deprecated and will be removed in Riiif 2.0. (called from new at /root/projects/spotlight/config/initializers/riiif.rb:1)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

class CreateFriendlyIdSlugs < ActiveRecord::Migration[4.2]
/root/projects/spotlight/db/migrate/20180110155041_create_friendly_id_slugs.rb:1:in `<top (required)>'

Caused by:
StandardError: Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for:

class CreateFriendlyIdSlugs < ActiveRecord::Migration[4.2]
/root/projects/spotlight/db/migrate/20180110155041_create_friendly_id_slugs.rb:1:in `<top (required)>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

What am I missing?

@camillevilla
Copy link
Member

hi @librarymark! What version of Rails are you currently using?

@librarymark
Copy link
Author

5.1.4

@jlicht
Copy link

jlicht commented Jan 10, 2018

I am seeing the same issue, also on Rails 5.1.4

@camillevilla
Copy link
Member

Ah. Looks like we're missing Rails versions for two migrations: devise_invitable_add_to_users.rb and create_friendly_id_slugs.rb. Add a version number to the migration and run rake db:migrate again.

class CreateFriendlyIdSlugs < ActiveRecord::Migration[5.1]

Let me know if that works!

@jlicht
Copy link

jlicht commented Jan 10, 2018

That works

@jlicht
Copy link

jlicht commented Jan 10, 2018

@camillevilla Thanks for your help.

I can edit the migration files after they're created, and successfully re-run rake db:migrate. However, since the migration failed, the installation process wasn't able to create the default admin user, and it's not clear to me what changes would be required in the database to make that happen. Any suggestions?

@camillevilla
Copy link
Member

camillevilla commented Jan 10, 2018

@jlicht No database changes needed once you run the migrations. If you use the following rake task, you'll be prompted to create an admin user:

bundle exec rake spotlight:admin

@jlicht
Copy link

jlicht commented Jan 10, 2018

Thanks, that worked

@camillevilla
Copy link
Member

camillevilla commented Jan 10, 2018

@jlicht @librarymark I'll close this issue for now (and open up a ticket for fixing the migration generator), but if you have any additional Spotlight questions, feel free to either:

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

3 participants