Propose increase size of stockmaster StockID and Description #812
Replies: 18 comments 17 replies
-
|
Fyi, I just discovered a stock ID can't include a "space" character, That calls for the classic "space to underscore" global replacement! |
Beta Was this translation helpful? Give feedback.
-
I can't foresee any technical issue, besides that StockID appears in many tables and a zillion queries and reports. All of them should be checked. It is not a complex change, but a long and tedious one.
OK for me. As a reference, OpenCart uses model (our StockID) as varchar(64) and product name (our description) as varchar(255). R |
Beta Was this translation helpful? Give feedback.
-
Interesting. Iiuc LongDescription is 65K char (8-bit, less if multi-byte) and you are using it more for ad hoc notes than a "long description" per se (e.g. the "Long Description" that might be required on a shipping document). My initial expectation was that LongDescription might be at most 5x the Description, or max 100 char. However, it seems at least for you, LongDescription can be MUCH longer. Does anyone know off the top of their head if there are scripts that assume LongDescription is much shorter, or assume a specific purpose? If everyone is treating LongDescription as 65K of ad hoc text, perhaps the legend in the GUI should be "Notes" instead of "Long Description" to better imply the intended use. What do you think? |
Beta Was this translation helpful? Give feedback.
-
|
Back to stockid, using ChangeColumnSize() to change stockid results in a foreign key error at least on MariaDb. I see other functions in UpgradeDB_mariadb.php disable foreign key checking, should CangeColumnSize() do this also or is there a better way? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
|
Can anyone say why the foreign key containts in the custitem table have embedded spaces in their names? Iiuc these are the ONLY foreign key constraints with spaces in their names and are, in the least, confusing special cases:
Would it be possible to remove the spaces? What would be involved? weberp/install/sql/tables/custitem.sql: |
Beta Was this translation helpful? Give feedback.
-
|
I think it is a typo error that should be corrected. R |
Beta Was this translation helpful? Give feedback.
-
|
Edit. Made original post a reply to @pakricard's instead to get back to the original topic - increasing stockid and description sizes. It seems I was naive thinking the only table with a foreign key to the stockmaster stockid column was the custitem table. After copy/pasting the name of the fk directly from mariadb cli output I was able to drop the constraint from the custitem table but then attempting to change the size of stockid resulted in an fk error in the bom table. After investigating, it seems there are many tables containing an explit fk relationship to stockmaster stockid. Btw, I don't know if the character at issue was actually a space or if it only appeared as a space and was actually e.g. a tab character. I don't think it would be difficult to use an upgrade xxx.php file to delete all the fk constraints in all the tables, adjust the sizes of parent and child tables and then re-create the fks, but before doing that, can anyone think of any issues? @pakricard @timschofield? Can it be presumed that all scripts that worked with a shorter stockid and description will continue to work as as expected when the stockid and description are shorter (i.e. comply with the current column size)? If there is no technical reason why stockid and description size can't be increased (albeit will be more work than originally expected), I think the choice comes down to either:
Larger values makes webERP more versatile which presumably adds value, while adding new "long" columns (which I a suspect is a well-known pattern and not something I just dreamed up) creates an additional layer of indirection, requires more scripts to be updated and increases the chaos factor. What do you think? WDYT? Drop fk's Try to change stockid size again What? How many tables do have a foreign key constraint to stockid? |
Beta Was this translation helpful? Give feedback.
-
|
P.S. There are 35 tables that have a "stockid" column, which I presume includes the 26 tables with an explicit foreign key constraint and means there are an additional 9 tables with an implicit foreign key relationship (treated as an fk by webERP code but without an explicit constraint). Does my analysis seem correct? |
Beta Was this translation helpful? Give feedback.
-
|
Sounds right to me. Some tables use stkcode to refer to stockid (I guess for historical reasons, some developers preferred one or another). Probably is time to unify all synonyms to stockid. Probably also unify all of them to varcahr, not char, to avoid type mismatches as PHP gets stricter on this issue at every new version. R |
Beta Was this translation helpful? Give feedback.
-
|
Fyi, found what appears to be the stockid foreign keys in two tables themselves being used as foreign keys in other tables. #835 |
Beta Was this translation helpful? Give feedback.
-
|
Progress Update - I have changed the size of stockmaster.stockid and all explicit foreign key constraint child columns and so far so good (fwiw, the code is in the drs/plm branch in my webERP fork) Implicit relationships to stockmaster.stockid will need brute force. I think I've found all the potential changes but some of them will be unrelated and I would very much appreciate your comments (otherwise I will need to search for and analyze all the code in all the files that uses each column, which will taking a huge amount of time and I could easily misunderstand the code leading to errors). Trying to use the simplest feedback approach, I think a wiki page might work well and is in keeping with the purpose of the wiki being for fine-tuning requirements before starting development. https://github.com/timschofield/webERP/wiki/PLM-Features-Increasing-stockid-size Please edit the page and add comments where applicable. A wiki page will allow multiple people to comment on the same potential change instead of replying seperately like in a discussion or issue. If you start a comment with your Github "@name" (e.g. "@dalers - this column is not related to stockid") will make it easy to see who said what (the page history will also show who said what but much more cumbersomely). Fwiw, I also updated the parent "PLM Features" wiki page with an outline of intended schema changes: https://github.com/timschofield/webERP/wiki/PLM-Features#database-changes |
Beta Was this translation helpful? Give feedback.
-
|
@timschofield @pakricard How would I create a compound foreign key relationship using the include/UpgradeDB functions? I need to re-add the stockserialmoves_ibfk_2 fk constraint in the stockserialmoves table exactly as it is now (after first deleting it in order to change the size of the child column). Interesting, the parent of the constraint is stockserialnumbers.stockid, which doesn't have a foreign key constraint to stockmaster.stockid. However, I'm assuming that how it is now is correct.
|
Beta Was this translation helpful? Give feedback.
-
|
I think I'm done :-) I would appreciate it if you could review the update script in the drs/plm branch of my fork https://github.com/dalers/webERP/blob/drs/plm/sql/updates/42.php - in particular where there are comments "TODO review by someone with more understanding of the code than the author" ;-) The script runs correctly on a vanilla installation (db created by the installer late fall 2025), Is there anything you would like done before I submit a PR with the update? Update procedure:
There are search screenshots for step 4 in the wiki https://github.com/timschofield/webERP/wiki/PLM-Features-Increasing-stockid-size |
Beta Was this translation helpful? Give feedback.
-
|
Hi @dalers : I executed update 43.php and got: I fixed this adding Regarding custitem.cust_part: Should be increased as well to varchar(64) for consistency? |
Beta Was this translation helpful? Give feedback.
-
|
Hi @dalers while looking at the above comment from @pakricard I noticed that the table schemas in install/sql/tables/ need updating for the new stockid length. Tim |
Beta Was this translation helpful? Give feedback.
-
I'm just not getting a) why it would be a huge amount of work (although I readily admit not having actually created such a script or even worked through the process manually, so don't actually know...), or b) why wouldn't you want to automate a simple manual process and eliminate the possibility of accidential errors, it seems low hanging fruit. |
Beta Was this translation helpful? Give feedback.
-
Thanks! :-) I just need to understand it first though. Can we continue the general installer discussion in a seperate new Discuss topic #865 (assuming you also think there is a benefit). For me, preventing ways that can cause webERP to create a broken db has a lot of merit, as does reducing developer effort on housekeeping activities. |
Beta Was this translation helpful? Give feedback.




Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm still working through importing stock items but an issue has arisen with the stock ID (part number), description (title) and long description (detail) being imported are larger than the webERP column sizes.
The maximum column widths in the data being imported are:
LongDescription is "text" which iiuc is 65K bytes, which is PNDetail in Parts&Vendors and has an max of 255 char so no issue. Fwiw, the absolute max for PNPartNumber (StockID) is 50 char and PNTitle (Description) is 255 char.
Q1. Are there any technical reasons why these column widths can't simply be increased to accomodate the data being imported? Would the only issues be table and report formating when scripts assume data will be shorter?
Q2. If there are no insurmountable technical reasons, would you be in favor of (or tolerant of) allowing the larger sizes in webERP?
Cheers,
Dale
Fwiw, posts that are somewhat related and in a general PLM theme include:
Z_ImportPartCodes.php fails Z_ImportPartCodes.php fails #741
Schema is missing an Item "Notes" field Schema missing stock item "Notes" #592
How to Import BOMs How to Import BOMs #591
What is purpose of Manufacturers and Brand Management? What is purpose of Manufacturers and Brand Management? #668
BOM item quantity needs more decimal places for accuracy BOM item quantity needs more decimal places for accuracy #702
Sales Orden Items with CSV with obsolete items error
(specifically Sales Orden Items with CSV with obsolete items error #808 (comment))
Beta Was this translation helpful? Give feedback.
All reactions