Sha256: 1b3288d0f03bd27bb24ac3cdd0323a85f0cfcff64c82e8a374e45a59b44cdca3
Contents?: true
Size: 861 Bytes
Versions: 21
Compression:
Stored size: 861 Bytes
Contents
class UpgradeSidebarObjects < ActiveRecord::Migration class Sidebar < ActiveRecord::Base include BareMigration end def self.up modify_tables_and_update(:add_column, Sidebar, :type, :string) do |sb| next if $schema_generator if sb.controller.nil? raise "Found a sidebar, \"#{sb.id}\", which doesn't know its controller so can't convert it. Settings are:\n #{sb.settings}. Please either correct the controller or delete the sidebar." end sb.type = sb.controller.camelcase + 'Sidebar' sb.save! end remove_column :sidebars, :controller end def self.down modify_tables_and_update(:add_column, Sidebar, :controller, :string) do |sb| next if $schema_generator sb.controller = sb[:type].underscore.sub(/_sidebar$/, '') sb.save! end remove_column :sidebars, :type end end
Version data entries
21 entries across 21 versions & 1 rubygems