# Stripping back all migrations: is it wise?

**URL:** <https://www.ruby-forum.com/t/stripping-back-all-migrations-is-it-wise/188567>\
**Category:** Rails\
**Created:** [May 13, 2010, 11:37pm UTC](https://www.ruby-forum.com/t/stripping-back-all-migrations-is-it-wise/188567 "2010-05-13T23:37:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fearless\_fool](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5e9695/32.png) [@fearless\_fool](https://www.ruby-forum.com/u/fearless_fool)\
**Post date:** [May 13, 2010, 11:37pm UTC](https://www.ruby-forum.com/t/stripping-back-all-migrations-is-it-wise/188567/1 "2010-05-13T23:37:42Z")

</div>

During this development project, I’ve evolved from “Total Rails Noob” to  
“Rails Tyro, Class IV”. (And I thank everyone on this list who has  
helped me along!)

I’ve also accrued 67 migrations as I’ve thrashed around and created  
tables, deleted tables, added columns, dropped columns, renamed columns,  
added indices to tables… you name it.

But I now have a reasonably stable set of models and tables.

Wouldn’t it make sense to “snapshot” the configuration and flush all the  
migrations? It seems I could replace all the existing migrations with  
the contents of schema.rb. And my guess is that it would speed up  
launch time (which is become an issue for me…)

Good idea? Bad idea? Do people do this? If so, is there some rake  
task to simplify the process?

TIA.

- ff

---

<div class="post-metadata">

**Author:** ![fearless\_fool](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5e9695/32.png) [@fearless\_fool](https://www.ruby-forum.com/u/fearless_fool)\
**Post date:** [May 13, 2010, 11:42pm UTC](https://www.ruby-forum.com/t/stripping-back-all-migrations-is-it-wise/188567/2 "2010-05-13T23:42:26Z")

</div>

Fearless F. wrote:

> Wouldn’t it make sense to “snapshot” the configuration and flush all the  
> migrations? It seems I could replace all the existing migrations with  
> the contents of schema.rb. And my guess is that it would speed up  
> launch time (which is become an issue for me…)

How would that speed up launch time? I could certainly see that it would  
speed up the initial migration when deploying for the first time and  
running your migrations on the production database, but that probably  
isn’t a huge deal.

I could be wrong, but I don’t see the issue.

---

<div class="post-metadata">

**Author:** ![fearless\_fool](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5e9695/32.png) [@fearless\_fool](https://www.ruby-forum.com/u/fearless_fool)\
**Post date:** [May 14, 2010, 1:14am UTC](https://www.ruby-forum.com/t/stripping-back-all-migrations-is-it-wise/188567/3 "2010-05-14T01:14:34Z")

</div>

Fearless F. wrote:

> During this development project, I’ve evolved from “Total Rails Noob” to  
> “Rails Tyro, Class IV”. (And I thank everyone on this list who has  
> helped me along!)
> 
> I’ve also accrued 67 migrations as I’ve thrashed around and created  
> tables, deleted tables, added columns, dropped columns, renamed columns,  
> added indices to tables… you name it.

Yes, that’s what happens.

> But I now have a reasonably stable set of models and tables.
> 
> Wouldn’t it make sense to “snapshot”

That is what db/schema.rb does. You should have that file in version  
control.

> the configuration and flush all the  
> migrations? It seems I could replace all the existing migrations with  
> the contents of schema.rb.

No, keep the migrations. (Some people advocate consolidating old  
migrations, but I’ve never done this.)

> And my guess is that it would speed up  
> launch time (which is become an issue for me…)

Then you guess wrong. Migrations have nothing at all to do with startup  
time.

> Good idea? Bad idea? Do people do this? If so, is there some rake  
> task to simplify the process?
> 
> TIA.
> 
> - ff

## Best,

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

---

<div class="post-metadata">

**Author:** ![fearless\_fool](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5e9695/32.png) [@fearless\_fool](https://www.ruby-forum.com/u/fearless_fool)\
**Post date:** [May 14, 2010, 2:09pm UTC](https://www.ruby-forum.com/t/stripping-back-all-migrations-is-it-wise/188567/4 "2010-05-14T14:09:10Z")

</div>

Your migrations are really just a set of steps to a specific point. I  
have seen and done ‘migration maintenance’ multiple ways.

On one team, there is a certain ‘sanctity’ to the notions of migrations,  
and they are all kept separate and unaltered. Blew it in your last  
migration? Well, make a new one and fix it. All the ugly history is  
there.

On another, at each general delivery release, migrations are accompanied  
with a ‘compaction’ of migrations for that release into a unified single  
step. As one person said, “No need to keep the dirty laundry laying  
about.”

Either way works, just depends on the situation. And as Marnen  
mentioned, version control is your friend no matter which method you  
choose.

---

<div class="post-metadata">

**Author:** ![fearless\_fool](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/5e9695/32.png) [@fearless\_fool](https://www.ruby-forum.com/u/fearless_fool)\
**Post date:** [May 14, 2010, 1:57am UTC](https://www.ruby-forum.com/t/stripping-back-all-migrations-is-it-wise/188567/5 "2010-05-14T01:57:21Z")

</div>

@Robert W.:

> How would that speed up launch time?  
> …  
> I could be wrong, but I don’t see the issue.

Meh. You are right. Chalk this brain bubble up to a solid week of 18  
hour coding sessions. My error.

@Marnen Laibow-Koser

> You should have that [db/schema.rb] in version control.

But of course! ‘fool’ != ‘stupid’ 🙂 🙂

- ff
