# Managing migrations

**URL:** <https://www.ruby-forum.com/t/managing-migrations/162525>\
**Category:** Rails\
**Created:** [March 10, 2009, 9:45pm UTC](https://www.ruby-forum.com/t/managing-migrations/162525 "2009-03-10T21:45:04Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [March 10, 2009, 9:45pm UTC](https://www.ruby-forum.com/t/managing-migrations/162525/1 "2009-03-10T21:45:04Z")

</div>

I have a migration “x” that when it runs self.up it adds a new column  
to a table, and of course when self. down is run it deletes said  
table…

After I ran this migration I continued to work and in the process  
added a couple other migrations. After a while I realized that the  
column migration “x” created was a mistake and I no longer need it. So  
I ran rake db:migrate:down VERSION=x to delete the column. It worked  
great, but the problem is whenever I added another migration than ran  
rake db:migrate, migration “x” ran its self.up again and the column I  
no longer wanted was built back into my schema.

What the best way to handle something like this? Is it insane to just  
manually delete a migration file to prevent it from ever being ran  
again?

Thanks heaps,  
Elliott

---

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [March 10, 2009, 9:53pm UTC](https://www.ruby-forum.com/t/managing-migrations/162525/2 "2009-03-10T21:53:22Z")

</div>

> What the best way to handle something like this? Is it insane to just  
> manually delete a migration file to prevent it from ever being ran  
> again?

Yeah, you can delete it. It’s just a file.

–  
Starr H.  
My blog: [http://starrhorne.com](http://starrhorne.com)  
Check out my Helpdesk RailsKit: [http://railskits.com/helpdesk/](http://railskits.com/helpdesk/)

---

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [March 10, 2009, 10:03pm UTC](https://www.ruby-forum.com/t/managing-migrations/162525/3 "2009-03-10T22:03:56Z")

</div>

On Mar 10, 2009, at 4:52 PM, Starr H. wrote:

> > What the best way to handle something like this? Is it insane to just  
> > manually delete a migration file to prevent it from ever being ran  
> > again?
> 
> Yeah, you can delete it. It’s just a file.
> 
> –  
> Starr H.  
> My blog: [http://starrhorne.com](http://starrhorne.com)  
> Check out my Helpdesk RailsKit: [http://railskits.com/helpdesk/](http://railskits.com/helpdesk/)

Just create another migration that is the opposite of this one.

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [March 10, 2009, 10:20pm UTC](https://www.ruby-forum.com/t/managing-migrations/162525/4 "2009-03-10T22:20:57Z")

</div>

So, create another migration that would undo what the old problem one  
does… Would that be considered a better practice over just deleting  
the one you no longer need or is it just a personal preference?

Thanks

On Mar 10, 5:02 pm, Rob B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [March 10, 2009, 10:38pm UTC](https://www.ruby-forum.com/t/managing-migrations/162525/5 "2009-03-10T22:38:35Z")

</div>

Thanks for the insight.

EG

---

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [March 11, 2009, 12:11am UTC](https://www.ruby-forum.com/t/managing-migrations/162525/6 "2009-03-11T00:11:17Z")

</div>

The answer gets a bit more strict if there are multiple developers  
involved. In that case, I’d always create the extra migration.

However, if you never checked the migration into source control, then  
migrate:down, change it and migrate:up (or just delete it), is the  
right thing to do even in a multi-user development environment.

-Rob

On Mar 10, 2009, at 5:37 PM, elliottg wrote:

> > > the one you no longer need or is it just a personal preference?  
> > > Starr H.  
> > > My blog:[http://starrhorne.com](http://starrhorne.com)  
> > > Check out my Helpdesk RailsKit:[http://railskits.com/helpdesk/](http://railskits.com/helpdesk/)

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid  
+1 513-295-4739  
Skype: rob.biedenharn

---

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [March 11, 2009, 1:41am UTC](https://www.ruby-forum.com/t/managing-migrations/162525/7 "2009-03-11T01:41:57Z")

</div>

elliottg wrote:

> no longer wanted was built back into my schema.
> 
> What the best way to handle something like this? Is it insane to just  
> manually delete a migration file to prevent it from ever being ran  
> again?
> 
> Thanks heaps,  
> Elliott

I’m just editing migration file to add/remove columns and don’t create  
new migrations to the same table until first branch/release version…  
then add new migration file (for the same table, if needed) and continue  
to add/remove columns until next branch/release version commit.

It’s silly to add migration file for each column change within one  
version…

tom

# –

Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache

# [www.meinlschmidt.com](http://www.meinlschmidt.com) www.maxwellrender.cz www.lightgems.cz

---

<div class="post-metadata">

**Author:** ![elliottg](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/b77776/32.png) [@elliottg](https://www.ruby-forum.com/u/elliottg)\
**Post date:** [March 10, 2009, 10:32pm UTC](https://www.ruby-forum.com/t/managing-migrations/162525/8 "2009-03-10T22:32:05Z")

</div>

> So, create another migration that would undo what the old problem one  
> does… Would that be considered a better practice over just deleting  
> the one you no longer need or is it just a personal preference?

If you’re in production, or far along in development it’s probably best  
to create the extra migration.

If you’re early in development, I’d just delete it to keep things clean.

SH

–  
Starr H.  
My blog: [http://starrhorne.com](http://starrhorne.com)  
Check out my Helpdesk RailsKit: [http://railskits.com/helpdesk/](http://railskits.com/helpdesk/)
