Sha256: 37609142ad1af4301f9837408955e94f6d927cfea66396bd7e9179a23288707a
Contents?: true
Size: 1.62 KB
Versions: 2
Compression:
Stored size: 1.62 KB
Contents
# Upgrade to Browsercms v3.4.0 class Browsercms340 < ActiveRecord::Migration def change # Prefix the correct namespace where class_names are not prefixed %w[HtmlBlock Category CategoryType Portlet FileBlock ImageBlock Tag].each do |content_type| update_content_types(content_type) update_connectors_table(content_type) end update_sitemap update_files standardize_foreign_keys_from_versions_tables_to_original_table end private def namespace_model(name) "Cms::#{name}" end def update_files %w[FileBlock ImageBlock].each do |content_type| Cms::AbstractFileBlock.update_all("type = '#{prefix(content_type)}'", "type = '#{content_type}'") end end def update_sitemap %w[Section Page Link Attachment].each do |addressable| Cms::SectionNode.where(:node_type=>addressable).each do |node| node.node_type = namespace_model(addressable) node.save! end end end def update_content_types(name) found = Cms::ContentType.named(name).first if found found.name = namespace_model(name) found.save! end end def update_connectors_table(name) Cms::Connector.where(:connectable_type => name).each do |connector| connector.connectable_type = prefix(name) connector.save! end end def standardize_foreign_keys_from_versions_tables_to_original_table tables = %w[attachment dynamic_view file_block html_block link page ] tables.each do |table| rename_column(prefix("#{table}_versions"), "#{table}_id", :original_record_id) if column_exists?(prefix("#{table}_versions"), "#{table}_id") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
browsercms-3.4.0.rc2 | db/migrate/20111130221145_browsercms340.rb |
browsercms-3.4.0.rc1 | db/migrate/20111130221145_browsercms340.rb |