there are 2 different ways:
copying all data to temp, deleting all records from the standard table, upgrading and then restoring from the temp to standard and extension
another way:
copying all data to temp, upgrading the tables, then restoring the customized code from temp to extension.
the first code with insert in using for the first approach.
for the second way, you need the filter the records on the table. insert the customized fields and modify