Question

Not possible to create MySQL database from schema.rb for Rails 4 app?

  • Posted on May 24, 2014
  • TintinAsked by Tintin

Hi,

I followed this tutorial to deploy my first Rails app on Ubuntu / Nginx / Unicorn: https://www.digitalocean.com/community/articles/how-to-launch-your-ruby-on-rails-app-with-the-digitalocean-one-click-image

However, in my Rails production log I see this:

E, [2014-05-24T11:48:34.711858 #13238] ERROR – : Mysql2::Error: Table ‘rails.users’ doesn’t exist: SELECT users.* FROM users WHERE users.remember_token IS NULL LIMIT 1 I, [2014-05-24T11:48:34.712349 #13238] INFO – : Completed 500 Internal Server Error in 48ms

When I take a closer look at my “rails” database I can see that it contains only one table (“schema_migrations”) where there should be more than a dozen.

Running commands like

RAILS_ENV=production rake db:migrate

or

RAILS_ENV=production rake db:create db:schema:load

seems to have no effect on the database. But strangely I don’t get any error messages when running those commands.

How can I create the database for my app from schema.rb?

Thanks for any help.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Have you tried running the commands separately? <br><pre>RAILS_ENV=production rake db:create <br>RAILS_ENV=production rake db:schema:load</pre>

Thanks a lot for your help. But actually that doesn’t change much. It still won’t create my database.

Let me revise that. You can do it the way you have it, but make sure you put a semicolon after the Rails environment.
<br>RAILS_ENV=production; rake db:create db:schema:load <br>They are two separate commands.