On Tue, Apr 7, 2015 at 8:57 AM, Heptagone H <[email protected]> wrote:

> I used scaffolding to generate my models, controllers, views etc. Originally
> I wrote the app to use sqlite3, but now that I want to move my app to a
> production environment with mysql or even postgres, I keep on getting an
> error involving foreign keys.

>     Mysql2::Error: Can't create table 'myapp_dev.#sql-50a3_a4' (errno: 150):
> ALTER TABLE `articles` ADD CONSTRAINT `fk_rails_e74ce85cbc`
>     FOREIGN KEY (`author_id`)
>       REFERENCES `authors` (`id`)

MySQL offers multiple table "engines"; make sure the default engine
isn't MyISAM, because that doesn't support foreign keys.

You can set your default to InnoDB, which does.

HTH,
-- 
Hassan Schroeder ------------------------ [email protected]
http://about.me/hassanschroeder
twitter: @hassan
Consulting Availability : Silicon Valley or remote

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/CACmC4yA%3Dr2yx81WKDx%2Bw37uUf8wdpTgR5Jpfb1UF_6%2BNnFbSiA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to