'This function is used in the list_field_to_reference migration.
For each value in the list field for each record in the original table,
they create one record in the new table that points back to the original record.
@param tablename_new      : name of the new table to which the list field needs to migrated
@param new_list_field     : name of the field in the new table which will hold the content of the list field
@param list_field_name    : name of the list field in the original table
@param table_old_id_field : name of the id field in the original table
@param tablename_old      : name of the original table'

@staticmethod
def _fill_the_new_table(tablename_new, new_list_field, list_field_name, table_old_id_field, tablename_old):

    update_dict = {}
    table_old = db[tablename_old]
    table_new = db[tablename_new]
    for row in db().select(table_old[table_old_id_field], table_old[list_field_name]):
        for element in row[list_field_name]:
            update_dict[new_list_field] = element
            update_dict[('%s_%s' % (tablename_old, table_old_id_field))] = row[table_old_id_field]
            table_new.insert(**update_dict)
