phreeze icon indicating copy to clipboard operation
phreeze copied to clipboard

Add field in the database

Open MarinoRaul opened this issue 11 years ago • 2 comments

Hello!

If I already assembling the project, and I want to add one more field in the database, and do not want rebuildear whole new project because I have code changes that would lose, add everything in the project, I have to add things in side Phreeze code?????? because change side project and not working, so I suspect you have to change files Phreeze side!

Thank you!

MarinoRaul avatar Mar 11 '13 00:03 MarinoRaul

Hey MarinoRaul, that's no problem - In Phreeze builder, there is a selection for "Package to Generate" and one of the choices is "Phreeze DAO Model Files Only"

As long as you have not been editing files within the Model/DAO folder (which is generally not necessary) then you can simply re-generate these files anytime you make a schema change and your app will now be up-to-date with the new database schema. This will also create a new model.js file as well, so be careful if you have editing that file.

There are 3 other places however that need to be manually edited in order to avoid overwriting your work. However an easy thing that you can do if you don't want to type it all by hand - generate a new complete Phreeze app and use those files to copy/paste the new bits into your existing code.

The three places you will need to update are:

  1. The controller - you will need to add the new field into the insert/update methods so that is it saved correctly.
  2. The template - you will need to add the new field into your table view if necessary and create an input control in the editor form.
  3. The relevant "page" javascript inside your scripts/app/ folder. In the method "updateModel" you'll need to add in your new field so that the browser passed the value to the server.

Those three parts are not that difficult to write yourself, but I will often generate a new app that I can use to copy/paste and let Phreeze Builder that bit of work for me. I hope this helps.

jasonhinkle avatar Mar 11 '13 19:03 jasonhinkle

@jasonhinkle is it possible that this information is outdated and there are more steps needed to add a new field? i've followed the instructions and still get an error while trying to add a new db item: http://cl.ly/image/2x2z372k1h2b/Screen%20Shot%202015-03-30%20at%204.59.23%20PM.png ("type" is the name of the new db column)

robertogalan avatar Mar 30 '15 20:03 robertogalan