# Small question about the relevance of the "database schema h

**URL:** <https://www.ruby-forum.com/t/small-question-about-the-relevance-of-the-database-schema-h/93520>\
**Category:** Rails\
**Created:** [April 4, 2006, 11:52am UTC](https://www.ruby-forum.com/t/small-question-about-the-relevance-of-the-database-schema-h/93520 "2006-04-04T11:52:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![travis\_michel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@travis\_michel](https://www.ruby-forum.com/u/travis_michel)\
**Post date:** [April 4, 2006, 11:52am UTC](https://www.ruby-forum.com/t/small-question-about-the-relevance-of-the-database-schema-h/93520/1 "2006-04-04T11:52:48Z")

</div>

I have developed 3 small applications using rails (nothing production  
worthy, just some small stuff “prototype” style). And I often end up  
changing my database scheme in the middle of development. I also use  
“script/generate scaffold” (this is somehow relevant to my question).  
Whenever I change my database schema I end up having to regenerate the  
scaffold. In the past this was okay, because I would not choose to  
overwrite files that I have worked on; but this raises a question…  
why does rails care if I change the schema?  
Effectively, the last time I regenerated the scaffolding I overwrote  
nothing; as far as I can tell, as an application developer, nothing  
changed between the time that I got the classic error of “database  
schema has changed” to now when the application works as I expect it.

I’m just wondering if this is some protection against developers who  
don’t know wtf (like me) or if this is some out of date annoyance.

sincerely, (and with much love too 😉  
travis michel.

---

<div class="post-metadata">

**Author:** ![travis\_michel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@travis\_michel](https://www.ruby-forum.com/u/travis_michel)\
**Post date:** [April 4, 2006, 2:58pm UTC](https://www.ruby-forum.com/t/small-question-about-the-relevance-of-the-database-schema-h/93520/2 "2006-04-04T14:58:52Z")

</div>

Hi Travis,

travis michel wrote:

> Whenever I change my database schema I  
> end up having to regenerate the scaffold.

Without knowing the particulars of your situation I can’t say for sure  
but,  
in many circumstances, a change in the db schema would not require the  
regen  
of the scaffold, only of the model. That won’t touch any of your view  
or  
controller code.

ruby script\generate model ModelName

HTH,  
Bill

---

<div class="post-metadata">

**Author:** ![travis\_michel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@travis\_michel](https://www.ruby-forum.com/u/travis_michel)\
**Post date:** [April 4, 2006, 3:35pm UTC](https://www.ruby-forum.com/t/small-question-about-the-relevance-of-the-database-schema-h/93520/3 "2006-04-04T15:35:52Z")

</div>

Usually once you’ve generated your models and other scaffolds for a  
given table or object, you almost never regenerate them again unless  
you’re in very early stages of working with a table and you’ve decided  
to wipe it out and start from scratch. You make any necessary subsequent  
changes by hand, because by that point you should already be customizing  
your views, models and controllers, and generating again would wipe out  
all your own code.

Scaffolding and generators in general are just for creating an initial  
skeleton for parts of your app. It is intended simply as a quick way to  
generate the files and directories a model or controller generally need.  
From there on, as you add fields to existing parts of your db schema,  
you add whatever code you need to your views (which you rewrite from  
scratch once you really start working on the app), you add relations,  
validations and other stuff like that to your models, you add more  
views, and so on, by hand.

travis michel wrote:

> I have developed 3 small applications using rails (nothing production  
> worthy, just some small stuff “prototype” style). And I often end up  
> changing my database scheme in the middle of development. I also use  
> “script/generate scaffold” (this is somehow relevant to my question).  
> Whenever I change my database schema I end up having to regenerate the  
> scaffold. In the past this was okay, because I would not choose to  
> overwrite files that I have worked on; but this raises a question…  
> why does rails care if I change the schema?  
> Effectively, the last time I regenerated the scaffolding I overwrote  
> nothing; as far as I can tell, as an application developer, nothing  
> changed between the time that I got the classic error of “database  
> schema has changed” to now when the application works as I expect it.
> 
> I’m just wondering if this is some protection against developers who  
> don’t know wtf (like me) or if this is some out of date annoyance.
> 
> sincerely, (and with much love too 😉  
> travis michel.

---

<div class="post-metadata">

**Author:** ![travis\_michel](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/e47c2d/32.png) [@travis\_michel](https://www.ruby-forum.com/u/travis_michel)\
**Post date:** [April 4, 2006, 3:57pm UTC](https://www.ruby-forum.com/t/small-question-about-the-relevance-of-the-database-schema-h/93520/4 "2006-04-04T15:57:21Z")

</div>

This sounds like a migrations solution.

Steve  
[http://www.smarkets.net](http://www.smarkets.net)
