Solved

What is the best practice for creating custom columns on database tables?

  • 8 February 2022
  • 1 reply
  • 301 views

Userlevel 6
Badge +5

I have been writing some customizations, and I have tried adding new columns to database tables in two different ways.

The first way involves creating UDFs inside the Customization Project editor.

The second involves direct modification of the database table at the SQL Server level.

In either case, we seem to be able to create a PXCache extension that can properly reference the field by its name, as long as we are working with the DAC attached to that table.

The obvious downside of method #2 is that there is no mechanism to keep track of these database modifications, unless some sort of patch file apparatus is created by the developer to ensure those columns are created when a new instance is installed or possibly upgraded. There is also the possibility of a naming collision if the developer uses a name for the column that Acumatica subsequently creates in a future release (future column collision).

I vastly prefer method number 2 due to its simplicity. However, as I am currently using it, it is hard to keep track of these changes over time as more column additions are made.

Does anyone have any suggestions on adding and tracking column changes to the database? I find UDF’s to be annoying, because of the forced usrxxxx naming convention and also because I find it annoying to manage these fields through the Customization Project editor, versus through SSMS and Visual Studio.

Does anyone have any suggestions for a future proof way to manage these database changes without having to use the Customization Project editor and UDF’s? It would be good/fine if the database changes were apparent in the Customization Project editor, I would just prefer not to have to manage them there.

icon

Best answer by markusray17 8 February 2022, 21:33

View original

1 reply

Userlevel 6
Badge +5

Short answer is no, not really. You can manage the fields in the database using SSMS but you will still have to remember to update the customization project(you can load the SQL modifications from the database in the customization project editor).

One of the teams at the Hackathon this year did create a project that would automatically create columns/tables defined in DACs upon publishing. Which in theory would allow you to manage everything through SSMS and then when you deployed the customization to another instance(Assuming the previously mentioned customization was deployed on that instance) it would automatically create the necessary database tables/columns. I am not certain how finished the project was though and there are a lot of potential edge cases that could cause issues.

 

One thing to note with the UsrXXXX naming is that(if I recall correctly) Acumatica uses that during upgrades to recognize user defined columns and make sure they get included when tables are modified.

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved