Bundle exec rake db:migrate error

➜ sharetribe git:(master) ✗ bundle exec rake db:migrate

    DEBUG   ↳ /Users/darren/.rbenv/versions/2.6.5/bin/rake:23
    INFO Migrating to CreateItems (20080806070738)
    DEBUG    (0.3ms)  SELECT RELEASE_LOCK('5284399111433957445')
    DEBUG   ↳ /Users/darren/.rbenv/versions/2.6.5/bin/rake:23
    rake aborted!
    StandardError: An error has occurred, all later migrations canceled:

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

      class CreateItems < ActiveRecord::Migration[4.2]
    /Users/darren/data/projects/sharetribe/db/migrate/20080806070738_create_items.rb:1:in `<main>'
    /Users/darren/.rbenv/versions/2.6.5/bin/bundle:23:in `load'
    /Users/darren/.rbenv/versions/2.6.5/bin/bundle:23:in `<main>'

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

      class CreateItems < ActiveRecord::Migration[4.2]
    /Users/darren/data/projects/sharetribe/db/migrate/20080806070738_create_items.rb:1:in `<main>'
/Users/darren/.rbenv/versions/2.6.5/bin/bundle:23:in `load'
/Users/darren/.rbenv/versions/2.6.5/bin/bundle:23:in `<main>'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)

Is that just me? Thanks for any help.

you should not run all migrations from the very beginning, just create database and load current structure:

   bundle exec rake db:create db:structure:load
1 Like

Thanks for help! The reason I need to run is because if I run

foreman start -f Procfile.static and go to http://0.0.0.0:5000 I got this error:

10:57:03 rails.1               | FATAL
10:57:03 rails.1               | FATAL ActiveRecord::PendingMigrationError (
10:57:03 rails.1               |
10:57:03 rails.1               | Migrations are pending. To resolve this issue, run:
10:57:03 rails.1               |
10:57:03 rails.1               |         bin/rails db:migrate RAILS_ENV=development
10:57:03 rails.1               |
10:57:03 rails.1               | ):
10:57:03 rails.1               | FATAL
10:57:03 rails.1               | FATAL lib/rack_middleware/enforce_ssl.rb:23:in `call'
10:57:03 rails.1               | lib/rack_middleware/health_check.rb:12:in `call'
^C10:58:30 system                | SIGINT received, starting shutdown
10:58:30 rails.1               | - Gracefully stopping, waiting for requests to finish
10:58:30 rails.1               | === puma shutdown: 2020-05-02 10:58:30 -0700 ===
10:58:30 rails.1               | - Goodbye!
10:58:30 rails.1               | Exiting

Thanks

In case you are installing new Sharetribe then you wouldn’t have to run migrations db:structure:load will create all the database schema, Otherwise ensure the migration release version is the same as rails version.
For example - if you are running rails 5 then change it to like this -
before -
class CreateItems < ActiveRecord::Migration[4.2]
After
class CreateItems < ActiveRecord::Migration[5.0]

I would be happy to discuss with for any further help on this
Aman kr
email/skype - mailtoamanam@gmail.com