I'm trying run a set of migrations on heroku. This is the beginning of the error.
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedTable: ERROR: relation "articles" does not exist
: ALTER TABLE "settings" ADD CONSTRAINT "fk_rails_679ac32a85"
FOREIGN KEY ("article_id")
REFERENCES "articles" ("id")
There are two migrations.
The first creates a settings table which references an Articles that has not been created (the next migration is supposed to make this table). The first migration looks like this:
class CreateSettings < ActiveRecord::Migration
def change
create_table :settings do |t|
t.string :commentaryid
t.string :logo
t.text :title
t.text :bannermessage
t.boolean :blog
t.string :default_ms_image
t.string :dark_color
t.string :light_color
t.string :commentarydirname
t.references :article, index: true
t.timestamps null: false
end
add_foreign_key :settings, :articles
end
end
Then the articles table is supposed to be created in the next migration file:
class CreateArticles < ActiveRecord::Migration
def change
create_table :articles do |t|
t.string :article_name
t.string :xml_file
t.string :xslt_file
t.references :setting, index: true
t.timestamps null: false
end
add_foreign_key :articles, :settings
end
end
What I don't understand is that I didn't have any trouble with this when I ran this migration on my development machine using sqlite.
So what's the deal.