# Production Migrations Failing

**URL:** <https://www.ruby-forum.com/t/production-migrations-failing/145386>\
**Category:** Rails\
**Created:** [August 8, 2008, 5:32pm UTC](https://www.ruby-forum.com/t/production-migrations-failing/145386 "2008-08-08T17:32:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_CSHess](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@Sean\_CSHess](https://www.ruby-forum.com/u/Sean_CSHess)\
**Post date:** [August 8, 2008, 5:32pm UTC](https://www.ruby-forum.com/t/production-migrations-failing/145386/1 "2008-08-08T17:32:38Z")

</div>

I obviously have no idea what I’m doing. My app is running fine  
locally. I just finished setting up my vps with mod\_rails, and it can  
run a simple app.

Then, I use git to checkout my app, and try to run the migrations.  
They work alright, except that in a couple of the migrations, I had  
added some sample records. So, in the first migration, I add a  
“games” table, with a title and description, then I call  
Game.create :title =\> ‘asdf’, :description =\> ‘asdf’ a couple of times  
for the different games. These games never show up in the database. I  
thought create was supposed to save the records to the db as well?

I think the problem is that I don’t have any idea how to deploy a  
rails app “the right way.” What am I missing?

Thanks

---

<div class="post-metadata">

**Author:** ![Sean\_CSHess](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@Sean\_CSHess](https://www.ruby-forum.com/u/Sean_CSHess)\
**Post date:** [August 8, 2008, 5:37pm UTC](https://www.ruby-forum.com/t/production-migrations-failing/145386/2 "2008-08-08T17:37:56Z")

</div>

On 8 Aug 2008, at 16:31, Sean C. Hess wrote:

> for the different games. These games never show up in the database. I  
> thought create was supposed to save the records to the db as well?

My guess would be failing validations.

Fred

---

<div class="post-metadata">

**Author:** ![Sean\_CSHess](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@Sean\_CSHess](https://www.ruby-forum.com/u/Sean_CSHess)\
**Post date:** [August 8, 2008, 5:39pm UTC](https://www.ruby-forum.com/t/production-migrations-failing/145386/3 "2008-08-08T17:39:41Z")

</div>

You’re right! Thanks! I had my Game model validating that it belonged  
to  
at least one category, and there is no way to do that in that migration  
(since the categories hadn’t been created yet).  
On Fri, Aug 8, 2008 at 9:36 AM, Frederick C.  
\<removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Sean\_CSHess](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@Sean\_CSHess](https://www.ruby-forum.com/u/Sean_CSHess)\
**Post date:** [August 8, 2008, 5:45pm UTC](https://www.ruby-forum.com/t/production-migrations-failing/145386/4 "2008-08-08T17:45:33Z")

</div>

On 8 Aug 2008, at 16:39, Sean C. Hess wrote:

> You’re right! Thanks! I had my Game model validating that it  
> belonged to at least one category, and there is no way to do that in  
> that migration (since the categories hadn’t been created yet).

That’s one good reason for not using models in migrations, you can get  
a mismatch between what the model was at the time the migration was  
written and what it is when the migration is run.  
If you’re only using the model to avoid writing raw sql, one work  
around is to put something like

class SomeMigration \< ActiveRecord::Migration  
class Game \< ActiveRecord::Base; end

def up  
…  
end  
…  
end

in your migration. You might need to call  
Game.reset\_column\_information after you’ve done the create\_table.

Fred
