Skip to content

Mixed deployment issue: Column added on `labels` causes 400 errors

The Project#create_labels method uses attributes, so when a migration runs that adds a new column to labels, the record no longer saves correctly and errors with :

unknown attribute 'lock_on_merge' for ProjectLabel.
1761   # rubocop: disable CodeReuse/ServiceClass                                                                                                           
1762   def create_labels                                                                                                                                   
1763     Label.templates.each do |label|                                                                                                                   
1764       params = label.attributes.except('id', 'template', 'created_at', 'updated_at', 'type')                                                          
1765       Labels::FindOrCreateService.new(nil, self, params).execute(skip_authorization: true)                                                            
1766     end                                                                                                                                               
1767   end                                                                                                                                                 
1768   # rubocop: enable CodeReuse/ServiceClass  

Seen in #421124 (closed)

Edited by Thong Kuah