"Fossies" - the Fresh Open Source Software Archive

Member "db/migrate/20170419000002_overview_role_ids.rb" (25 Mar 2021, 656 Bytes) of package /linux/www/zammad-4.0.0.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "20170419000002_overview_role_ids.rb": 3.4.1_vs_3.5.0.

    1 class OverviewRoleIds < ActiveRecord::Migration[4.2]
    2   def up
    3 
    4     # return if it's a new setup
    5     return if !Setting.exists?(name: 'system_init_done')
    6 
    7     create_table :overviews_roles, id: false do |t|
    8       t.integer :overview_id
    9       t.integer :role_id
   10     end
   11     add_index :overviews_roles, [:overview_id]
   12     add_index :overviews_roles, [:role_id]
   13     Overview.connection.schema_cache.clear!
   14     Overview.reset_column_information
   15     Overview.all.each do |overview|
   16       next if overview.role_id.blank?
   17 
   18       overview.role_ids = [overview.role_id]
   19       overview.save!
   20     end
   21     remove_column :overviews, :role_id
   22 
   23     Cache.clear
   24   end
   25 
   26 end