Sha256: 6de70bd2ebc499d9539a10c84cfdde15efd396f236e2451ad4231d2dde1633fd
Contents?: true
Size: 768 Bytes
Versions: 2
Compression:
Stored size: 768 Bytes
Contents
class MigrateFromRailsAdminSettingsToThecoreSettings < ActiveRecord::Migration[7.0] 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
2 entries across 2 versions & 1 rubygems