20230825101042_show_package_url.rb 551 B

12345678910111213141516171819
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. class ShowPackageUrl < ActiveRecord::Migration[6.1]
  3. def change
  4. # return if it's a new setup
  5. return if !Setting.exists?(name: 'system_init_done')
  6. add_column :packages, :url, :string, limit: 512
  7. Package.reset_column_information
  8. Package.find_each do |package|
  9. json_file = Package._get_bin(package.name, package.version)
  10. data = JSON.parse(json_file)
  11. next if data['url'].blank?
  12. package.update!(url: data['url'])
  13. end
  14. end
  15. end