Run migrations from a gem

Imagine that you are trying to update to the latest gem you are using, then you run your test suite and you get an error similar to this depending on your database adapter:

            Mysql2::Error: Table

For this example, I'm going to use solidus_paypal_braintree.

Got to your Gemfile

Add the version of the gem you want to update

gem 'solidus_paypal_braintree', '~> 0.3.0'  


$ bundle

Run your test suite:

$ rspec spec/

And if you get something like this:

            Mysql2::Error: Table

That means there are some migrations that you need to copy from your gem, so for that, you can use this:

bundle exec rake railties:install:migrations FROM=solidus_paypal_braintree  

Then you are going to see some new files related to migrations.

After that run in your local environment:

$ rake db:migrate

You're done, Now run your test suite to bulletproof that everything is in place.

Thank you for reading!

Victor Velazquez

Coder, Musician, Startups, Passionate Dancer & Life Lover. Director of Engineering at MagmaLabs, Co-founder of Web Dev Talks, Co-founder of Voltaire, Co-founder of Paqkit, Ex-co-founder of Zaznova.

Subscribe to The zazvick's blog

Get the latest posts delivered right to your inbox.

or subscribe via RSS with Feedly!