20230808070608_issue_4530_notes_sans_images.rb 843 B

123456789101112131415161718192021222324
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Issue4530NotesSansImages < ActiveRecord::Migration[6.1]
  3. def up
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. # This was already migrated Issue4050ImageInNote migration
  7. # However, new installations were created with a wrong seed value
  8. # Seed values are now changed
  9. # Rerunning this migration to set correct values
  10. # In systems set up in between previous migration and the seed files fix
  11. [User, Organization, Group].each do |klass|
  12. note_attr = ObjectManager::Attribute.for_object(klass).find_by(name: :note)
  13. next if note_attr.blank?
  14. next if note_attr.data_option[:no_images] == true
  15. note_attr.data_option[:no_images] = true
  16. note_attr.save!
  17. end
  18. end
  19. end