# Preserving data in production

**URL:** <https://www.ruby-forum.com/t/preserving-data-in-production/147504>\
**Category:** Rails\
**Created:** [September 2, 2008, 4:00pm UTC](https://www.ruby-forum.com/t/preserving-data-in-production/147504 "2008-09-02T16:00:02Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [September 2, 2008, 4:00pm UTC](https://www.ruby-forum.com/t/preserving-data-in-production/147504/1 "2008-09-02T16:00:02Z")

</div>

I’ve made some pretty major changes to my applications structure,  
including regenerating the migrations. Rather than adding a column here  
and there I just did this…

rake db:migrate VERSION=0

Then edited my migration files with the new column names and types I  
required (only a couple of tables affected), I’ve then done…

rake db:migrate

and that’s brought in all the changes, it blatted all the data of course  
but the schema is now where I want it.

So what I’ve described above is all on my mac locally (the dev site).

So the thing is, what can I now do in production to preserve all the  
data?

Any tips for me?

---

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [September 2, 2008, 4:21pm UTC](https://www.ruby-forum.com/t/preserving-data-in-production/147504/2 "2008-09-02T16:21:55Z")

</div>

On 2 Sep 2008, at 15:00, bingo bob wrote:

> rake db:migrate
> 
> and that’s brought in all the changes, it blatted all the data of  
> course  
> but the schema is now where I want it.
> 
> So what I’ve described above is all on my mac locally (the dev site).
> 
> So the thing is, what can I now do in production to preserve all the  
> data?

instead of doing what you did, create migrations that add, remove or  
change columns/tables as required.

Fred

---

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [September 2, 2008, 4:47pm UTC](https://www.ruby-forum.com/t/preserving-data-in-production/147504/3 "2008-09-02T16:47:40Z")

</div>

I thought I might get that answer!  
Being that I’ve done it though, any tips?

---

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [September 2, 2008, 5:30pm UTC](https://www.ruby-forum.com/t/preserving-data-in-production/147504/4 "2008-09-02T17:30:03Z")

</div>

On 2 Sep 2008, at 15:47, bingo bob wrote:

> I thought I might get that answer!  
> Being that I’ve done it though, any tips?

Revert the changes 🙂

Fred

---

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [September 3, 2008, 5:22pm UTC](https://www.ruby-forum.com/t/preserving-data-in-production/147504/5 "2008-09-03T17:22:00Z")

</div>

On 3 Sep 2008, at 17:10, bingo bob wrote:

> OK, thanks, well not an option to revert, gone too far.
> 
> Thing is I have various tables in production, some of which (most) are  
> easy to recreate if I blow the data out. Question is, there are some  
> tables blog entries and page contents that I’d like to preserve the  
> data  
> for, I haven’t touched the migrations for these.

You can probably hack around to only run down/up on some migrations.  
don’t know if there’s anything builtin for that.

---

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [September 3, 2008, 5:39pm UTC](https://www.ruby-forum.com/t/preserving-data-in-production/147504/6 "2008-09-03T17:39:10Z")

</div>

> You can probably hack around to only run down/up on some migrations.  
> don’t know if there’s anything builtin for that.

That’s what I figured might be possible, any clues as to how to do this  
being as I’ve got 16 migration files in development, under svn control?

---

<div class="post-metadata">

**Author:** ![bingobob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e480ec/32.png) [@bingobob](https://www.ruby-forum.com/u/bingobob)\
**Post date:** [September 3, 2008, 5:10pm UTC](https://www.ruby-forum.com/t/preserving-data-in-production/147504/7 "2008-09-03T17:10:50Z")

</div>

OK, thanks, well not an option to revert, gone too far.

Thing is I have various tables in production, some of which (most) are  
easy to recreate if I blow the data out. Question is, there are some  
tables blog entries and page contents that I’d like to preserve the data  
for, I haven’t touched the migrations for these.

Can I do this?

bb.
