> On 24 Oct 2018, at 16:52, Two Way Communications via 4D_Tech > <[email protected]> wrote: > > The process seems quite cumbersome: to start, I need to remove the ‘primary > key’ flag from all the ID fields
Rudy - Just to add to the many useful contributions made so far, I found a way to do this in a few seconds which makes the process almost painless. (Courtesy of the late but much celebrated Ortwin Zilgen). The approach is: 1: run the code below to add keys to all tables. (This will keep 4D backup happy and let you do your replication) 2: carry on as usual using your IDs as “logical keys” or “business keys” as I call them, and remain blissfully ignorant of the UUID layer Ortwin’s code that he sent me is posted below. Best Regards Peter ****** Generate Primary Keys for All Tables ****** ` `. By Ortwin Zilgen ******************************************************* C_LONGINT($i;$P_SIZE) C_TEXT($tableName_t) $fieldName:="pkUUID" $P_SIZE:=Get last table number For ($i;1;$P_SIZE) If (Is table number valid($i)) $tableName_t:=Table name($i) $statement_t:="ALTER TABLE ["+$tableName_t+"] ADD "+$fieldName+" UUID AUTO_GENERATE PRIMARY KEY;" Begin SQL EXECUTE IMMEDIATE:$statement_t; End SQL End if End for ********************************************************************** 4D Internet Users Group (4D iNUG) Archive: http://lists.4d.com/archives.html Options: https://lists.4d.com/mailman/options/4d_tech Unsub: mailto:[email protected] **********************************************************************

