# Extending baked app and database

**URL:** <https://discourse.cakephp.org/t/extending-baked-app-and-database/1215>\
**Category:** Need Help\
**Created:** [September 22, 2016, 9:17am UTC](https://discourse.cakephp.org/t/extending-baked-app-and-database/1215 "2016-09-22T09:17:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheMiller](https://avatars.discourse-cdn.com/v4/letter/t/3ec8ea/32.png) [@TheMiller](https://discourse.cakephp.org/u/TheMiller)\
**Post date:** [September 22, 2016, 9:17am UTC](https://discourse.cakephp.org/t/extending-baked-app-and-database/1215/1 "2016-09-22T09:17:40Z")

</div>

Hello,

maybe this is a noob-question, but I need to know this. I think I’m just getting better in cake. But I try to completely plan my db structure. But this isn’t possible in all cases, so I wanted to know, what to do when I extend my already baked application by modifing the db structure or by adding new models which have relations to already baked models.

Case 1 - Modifing DB after bake  
When I alter the db by adding/renaming a column, then only the model changes (except test-classes). Right?  
So when I add a field, i have nothing to add in the models, except the validators, right? All object-properties of the model (representing) the database are available automatically. So only the Table-File is being touched.

Case 2 - Adding tables with relations to baked models  
When I add new tables which should be associated to already baked models, I only have to define the association in the corresponding table files.  
The other files files, which are already baked have not to be touched.

Am I missing something, or did I get this correctly? Please fulfill my explanations if neccessary.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![jimgwhit](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/jimgwhit/32/378_2.png) [@jimgwhit](https://discourse.cakephp.org/u/jimgwhit)\
**Post date:** [September 23, 2016, 3:52am UTC](https://discourse.cakephp.org/t/extending-baked-app-and-database/1215/2 "2016-09-23T03:52:08Z")

</div>

In the long run, you would be better off forgetting about bake and write every line of code yourself. Not to say a copy and paste is fine sometimes. I tryed bake, it takes longer fixing than it would me just type the code in. But again I am old school, Used to weld with 7018 rod, and from the have to work to earn a living era. And I have a habit of giving very straight to the point answers to questions. Maybe a hypnosis could make you forget you ever heard the word cakebake.

---

<div class="post-metadata">

**Author:** ![TheMiller](https://avatars.discourse-cdn.com/v4/letter/t/3ec8ea/32.png) [@TheMiller](https://discourse.cakephp.org/u/TheMiller)\
**Post date:** [September 23, 2016, 7:22am UTC](https://discourse.cakephp.org/t/extending-baked-app-and-database/1215/3 "2016-09-23T07:22:47Z")

</div>

Maybe or maybe not.

But this doesn’t answer the question. Even if I would code everything myself not using bake, I have to know, what to do in these cases above to extend the app properly.

I hope you know what I mean.

This question is just a general question. Maybe I explained everything correctly, or I did forget something to mention. But I want to be sure if I’m extending my app the “correct way”.

Thanks

---

<div class="post-metadata">

**Author:** ![rrd](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/rrd/32/113_2.png) [@rrd](https://discourse.cakephp.org/u/rrd)\
**Post date:** [September 23, 2016, 11:39am UTC](https://discourse.cakephp.org/t/extending-baked-app-and-database/1215/4 "2016-09-23T11:39:02Z")

</div>

Yes, it is something like that in most of the cases, except you have some really special thing in your models.

Perhaps views can change if you added / renamed db fields.

---

<div class="post-metadata">

**Author:** ![TheMiller](https://avatars.discourse-cdn.com/v4/letter/t/3ec8ea/32.png) [@TheMiller](https://discourse.cakephp.org/u/TheMiller)\
**Post date:** [September 23, 2016, 4:21pm UTC](https://discourse.cakephp.org/t/extending-baked-app-and-database/1215/5 "2016-09-23T16:21:25Z")

</div>

Thank you for the answer. For views, it is clear, that they may change. But I wouldn’t believe, that extending/alering is that simple regarding models.

Thanks.

---

<div class="post-metadata">

**Author:** ![rrd](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/rrd/32/113_2.png) [@rrd](https://discourse.cakephp.org/u/rrd)\
**Post date:** [September 26, 2016, 2:55pm UTC](https://discourse.cakephp.org/t/extending-baked-app-and-database/1215/6 "2016-09-26T14:55:39Z")

</div>

Thanks to bake it is! 😃
