# Redefining rename\_column?

**URL:** <https://www.ruby-forum.com/t/redefining-rename-column/170067>\
**Category:** Rails\
**Created:** [June 11, 2009, 9:56pm UTC](https://www.ruby-forum.com/t/redefining-rename-column/170067 "2009-06-11T21:56:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![plambert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9d8465/32.png) [@plambert](https://www.ruby-forum.com/u/plambert)\
**Post date:** [June 11, 2009, 9:56pm UTC](https://www.ruby-forum.com/t/redefining-rename-column/170067/1 "2009-06-11T21:56:03Z")

</div>

I would like to prevent rename\_column from working in certain  
circumstances, so I was trying to redefine rename\_column. However, it  
seems that the adapter’s definition loads afterward and wipes out what  
I put in. I have successfully overridden add\_column, so I am  
confident that I have the definition in the right module. Is there a  
way to force the database adapter to load, so I can override is  
(adapter-specific) rename\_column? (I guess I might be able to  
override each database-specific rename\_column, but I don’t like that  
solution.)

Thanks,  
–Paul

---

<div class="post-metadata">

**Author:** ![plambert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9d8465/32.png) [@plambert](https://www.ruby-forum.com/u/plambert)\
**Post date:** [June 11, 2009, 10:28pm UTC](https://www.ruby-forum.com/t/redefining-rename-column/170067/2 "2009-06-11T22:28:50Z")

</div>

Paul L. wrote:

> I would like to prevent rename\_column from working in certain  
> circumstances, so I was trying to redefine rename\_column.  
> […]

Can I ask what you’re trying to accomplish here? In general, it seems  
to me that preventing something like this from working will probably be  
confusing to anyone maintaining the code.

## Best,

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

---

<div class="post-metadata">

**Author:** ![plambert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9d8465/32.png) [@plambert](https://www.ruby-forum.com/u/plambert)\
**Post date:** [June 11, 2009, 10:42pm UTC](https://www.ruby-forum.com/t/redefining-rename-column/170067/3 "2009-06-11T22:42:58Z")

</div>

Some of the tables in our system hold data entered by users of the web  
site. I am trying to stop one of us (developers) from shooting  
ourselves in the foot by accidentally modifying those tables in a way  
that would lose data. My plan is to capture calls to table change  
commands, record some of them (e.g. add\_column) so that they can be  
played back later on the production database, and prohibit others  
(e.g. remove\_column).

On Jun 11, 4:28 pm, Marnen Laibow-Koser \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![plambert](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/9d8465/32.png) [@plambert](https://www.ruby-forum.com/u/plambert)\
**Post date:** [June 11, 2009, 11:30pm UTC](https://www.ruby-forum.com/t/redefining-rename-column/170067/4 "2009-06-11T23:30:40Z")

</div>

Paul L. wrote:

> Some of the tables in our system hold data entered by users of the web  
> site. I am trying to stop one of us (developers) from shooting  
> ourselves in the foot by accidentally modifying those tables in a way  
> that would lose data.

This is almost certainly a bad idea. You should not be sandboxing the  
developers – they should have full access to change what needs to be  
changed. If you can’t trust your developers to use that access wisely,  
fire them. If the data is that important, back it up. If developers  
really shouldn’t have that level of access to the DB at all, then don’t  
grant those privileges to the relevant DB user.

But hackish solutions like what you’re talking about will just make the  
developers’ lives harder for no good reason.

## Best,

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