Today I want to stop your attention on how Acumatica handles updates for custom tables/columns.
You know you can add all these custom columns to the standard tables in Acumatica, but in this case you several issues
- Each new column has to have an Usr prefix to each column. That is required to split standard and custom columns in one table
- You columns depend on Acumatica table. In case Acumatica have any changes in the tables, you columns may also be affected. But do not worry, they are never be deleted.
So in case of multiple custom columns it might be good idea to split them in custom table. Using Acumatica framework you easily can create as many custom tables as you wish.
Also even if you need to link new columns to original records, you always can use Extension Tables, that actually give you ability to have benefits of custom columns and new table.
Ok, now we have a new table, but how to support it in case we need to add a new column there?
Adding Table to Customization Project
First of all what we need to do - add custom table to Acumatica Customization Project
Changing of Columns
Now you can do any changes, and as my personal experience the best and easiest way to do changes is actually directly use MS Sql Server Management Studio. You can use SQL to add/change columns or directly use table designer, the main thing is just to have a new table definition in DB.
If you are finished with changes and ready to commit, you can just go to Customization Browser and update table definition form database.
Also note that for performance reasons Acumatica caches table schema in memory and refresh is only once in a while. So that means that sometimes you need to restart site to load latest changes from DB.
During customization publication Acumatica will automatically adjust table columns. So
- If the table does not have column defined in project, it will be added
- If there is a column in DB, that does not exists in schema, it will be deleted
- If there is column with 'USR' prefix, that it will be used as custom column and will not be deleted from table in any case.
- Acumatica, will rearrange columns sequence to match table definition
In case you want to have a data manipulation script (like "UPDATE table SET ... WHERE ..."), that you can have a custom SQL scripts.
- Add new columns in all tables defined in customization project
- Run custom scripts to manipulated with data
- Recreate all tables to delete removed columns and update columns sequence.
Also great news - it will work fine with SQL and MySQL, because Acumatica actually parse your SQL before executing it and does some optimization/transformation.
Have a nice customization!