seeds.rb 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Copyright (C) 2012-2023 Zammad Foundation, https://zammad-foundation.org/
  2. # This file should contain all the record creation needed to seed the database with its default values.
  3. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
  4. #
  5. # Examples:
  6. #
  7. # cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
  8. # Mayor.create(:name => 'Emanuel', :city => cities.first)
  9. # clear old caches to start from scratch
  10. Rails.cache.clear
  11. # this is the __ordered__ list of seed files
  12. # extend only if needed - try to add your changes
  13. # to the matching one of the existing files
  14. seeds = %w[settings user_nr_1 signatures roles permissions groups links ticket_state_types ticket_states ticket_priorities ticket_article_types ticket_article_senders macros community_user_resources overviews channels report_profiles chats object_manager_attributes schedulers triggers core_workflow]
  15. # loop over and load all seedfiles
  16. # files will get executed automatically
  17. seeds.each do |seed|
  18. # we use load here to be able to re-seed in one process (test env)
  19. load Rails.root.join('db', 'seeds', "#{seed}.rb")
  20. end
  21. # set basic Rails server settings via environment variables
  22. Setting.set('http_type', ENV['ZAMMAD_HTTP_TYPE']) if ENV['ZAMMAD_HTTP_TYPE']
  23. Setting.set('fqdn', ENV['ZAMMAD_FQDN']) if ENV['ZAMMAD_FQDN']
  24. # reset primary key sequences
  25. DbHelper.import_post
  26. # install locales and translations
  27. Locale.create_if_not_exists(
  28. locale: 'en-us',
  29. alias: 'en',
  30. name: __('English (United States)'),
  31. )
  32. Locale.sync
  33. Translation.sync
  34. Calendar.init_setup
  35. # install all packages in auto_install
  36. Package.auto_install