Sha256: aea524b1a1feefd91ba5e45f2264529a39ff9a31227f61f9392282e18e5023c5
Contents?: true
Size: 768 Bytes
Versions: 7
Compression:
Stored size: 768 Bytes
Contents
class MigrateFromRailsAdminSettingsToThecoreSettings < ActiveRecord::Migration[5.2] module RailsAdminSettings class Setting < ActiveRecord::Base self.table_name = "rails_admin_settings" end end def change if RailsAdminSettings::Setting.table_exists? puts "Table Exists, trying to migrate older values to new ThecoreSettings::Setting Table" RailsAdminSettings::Setting.all.each do |old_setting| new_setting = ThecoreSettings::Setting.find_or_initialize_by old_setting.attributes.except("id", "created_at", "updated_at") unless new_setting.save puts new_setting.errors.full_messages.join("\n") end end else puts "Table Does not Exists, nothing to do! Yay" end end end
Version data entries
7 entries across 7 versions & 1 rubygems