write foreign key for all model updated