"Fossies" - the Fresh Open Source Software Archive

Member "db/migrate/20150979000001_update_timestamps.rb" (25 Mar 2021, 636 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 "20150979000001_update_timestamps.rb": 3.4.1_vs_3.5.0.

    1 class UpdateTimestamps < ActiveRecord::Migration[4.2]
    2   def up
    3     # return if it's a new setup
    4     return if !Setting.exists?(name: 'system_init_done')
    5 
    6     # get all models
    7     Models.all.each_value do |value|
    8       next if !value
    9       next if !value[:attributes]
   10 
   11       if value[:attributes].include?('updated_at')
   12         ActiveRecord::Migration.change_column value[:table].to_sym, :updated_at, :datetime, limit: 3, null: false
   13       end
   14       if value[:attributes].include?('created_at')
   15         ActiveRecord::Migration.change_column value[:table].to_sym, :created_at, :datetime, limit: 3, null: false
   16       end
   17     end
   18   end
   19 end