# Keep fix data in database table while deploying

**URL:** <https://www.ruby-forum.com/t/keep-fix-data-in-database-table-while-deploying/167903>\
**Category:** Rails\
**Created:** [May 13, 2009, 8:09pm UTC](https://www.ruby-forum.com/t/keep-fix-data-in-database-table-while-deploying/167903 "2009-05-13T20:09:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [May 13, 2009, 8:09pm UTC](https://www.ruby-forum.com/t/keep-fix-data-in-database-table-while-deploying/167903/1 "2009-05-13T20:09:14Z")

</div>

Hi there,

I’m pretty new to rails, but so far it’s fun!

But I couldn’t find an answer to solve this problem the rails way:

I deploy a webapp using capistrano and everything works fine.

In my db I have a table that has some fix entries, like “categories”,  
and I want them to move to the deployment server.

What’s the best way to make the data of a table move with it, when  
deploying?

Regards,

Chris

---

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [May 13, 2009, 9:04pm UTC](https://www.ruby-forum.com/t/keep-fix-data-in-database-table-while-deploying/167903/2 "2009-05-13T21:04:03Z")

</div>

I would think you can do this with seed data OR just have one of your  
migration files add the categories like

%w(cat1 cat2 cat3 cat4).each do |cat|  
Category.create(:name =\> cat)  
end

Normally for production this is only done once then it stays in the db  
for each deployment after that. It almost sounds like you clear the db  
when you deploy is that correct? Is this for a test server or  
development?

---

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [May 13, 2009, 9:45pm UTC](https://www.ruby-forum.com/t/keep-fix-data-in-database-table-while-deploying/167903/3 "2009-05-13T21:45:51Z")

</div>

Hi Freddy,

thanks for the hint, I guess this helps me out. 🙂

At this point, I only set up the db structure in migrations, no data  
at all.  
So no data could be transfered to the server…

---

<div class="post-metadata">

**Author:** ![dacbo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b9e5f3/32.png) [@dacbo](https://www.ruby-forum.com/u/dacbo)\
**Post date:** [May 14, 2009, 9:36am UTC](https://www.ruby-forum.com/t/keep-fix-data-in-database-table-while-deploying/167903/4 "2009-05-14T09:36:06Z")

</div>

Chris wrote:

> Hi Freddy,
> 
> thanks for the hint, I guess this helps me out. 🙂
> 
> At this point, I only set up the db structure in migrations, no data  
> at all.  
> So no data could be transfered to the server…

Setting up data in migrations is possible but awkward if you have more  
than a very small number of records. Fortunately, there are a couple of  
gems and plugins designed for seed data (I’ve never used any of them,  
but a quick Web search should get you some useful info), and it wouldn’t  
be at all hard to write a simple Rake task or config item that reads  
data out of a YAML file or something.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid
