Forums / Code Collaboration / Database and New Plugin

Database and New Plugin

Views: 2,345

Results 1 to 3 of 3
25 Nov 2021, 2:16 PM
#1
g2ktcf avatar

g2ktcf

Totally Zenned

Join Date:
Feb 2011
Location:
Lumberton, TX
Posts:
636
Plugin Contributions:
0

Database and New Plugin

I am working on a new plug-in and I need to store "last reported inventory values." The easiest thing to do is to add a field to the products table (SBA is another consideration for later). Is that considered the best practice? I guess as long as I include both field creation in the install script and deletion in the uninstall script I should be okay, right?

25 Nov 2021, 2:22 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,119
Plugin Contributions:
56

Re: Database and New Plugin

g2ktcf:

I am working on a new plug-in and I need to store "last reported inventory values." The easiest thing to do is to add a field to the products table (SBA is another consideration for later). Is that considered the best practice? I guess as long as I include both field creation in the install script and deletion in the uninstall script I should be okay, right?
FWIW, adding that field to the **products **table would be the approach I'd use. Just name the field 'appropriately' so that it's not likely to be overwritten by a Zen Cart upgrade that adds such a field.

25 Nov 2021, 2:52 PM
#3
g2ktcf avatar

g2ktcf

Totally Zenned

Join Date:
Feb 2011
Location:
Lumberton, TX
Posts:
636
Plugin Contributions:
0

Re: Database and New Plugin

lat9:

FWIW, adding that field to the **products **table would be the approach I'd use. Just name the field 'appropriately' so that it's not likely to be overwritten by a Zen Cart upgrade that adds such a field.

Good Point, I never considered that another upgrade would overwrite it! Thanks!