Skip to content

Commit

Permalink
Add data migration for attribute default values.
Browse files Browse the repository at this point in the history
On certain instances of the Open Build Service the default
attribute values got lost, since they are only created once
at the first setup by the seeds. This causes failing validations
when creating certain attribute, since they rely on the default values.

Fixes #8143
  • Loading branch information
krauselukas committed Sep 3, 2019
1 parent 21b033c commit c0f2e24
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions src/api/db/data/20190902110039_add_attribute_default_values.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class AddAttributeDefaultValues < ActiveRecord::Migration[5.2]
def up
ans = AttribNamespace.where(name: 'OBS').first
return unless ans

at = ans.attrib_types.where(name: 'QualityCategory').first
at.default_values.where(value: 'Development', position: 1).first_or_create if at

at = ans.attrib_types.where(name: 'MaintenanceIdTemplate').first
at.default_values.where(value: '%Y-%C', position: 1).first_or_create if at
end

def down
raise ActiveRecord::IrreversibleMigration
end
end
2 changes: 1 addition & 1 deletion src/api/db/data_schema.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# encoding: UTF-8
DataMigrate::Data.define(version: 20190228170655)
DataMigrate::Data.define(version: 20190902110039)

0 comments on commit c0f2e24

Please sign in to comment.