Sha256: 48b96b683f915a9fbb8a3ad2aee9ef9a5f0ab6dc7721e3bfd55b8fdc17bb6cfb

Contents?: true

Size: 856 Bytes

Versions: 66

Compression:

Stored size: 856 Bytes

Contents

# change post structure to optimize query speed
class RenameColumnPosts < CamaManager.migration_class
  def change
    remove_column "#{PluginRoutes.static_system_info["db_prefix"]}posts", :comment_count
    add_column "#{PluginRoutes.static_system_info["db_prefix"]}posts", :post_order, :integer, default: 0
    add_column "#{PluginRoutes.static_system_info["db_prefix"]}posts", :taxonomy_id, :integer, default: nil, index: true
    CamaleonCms::Post.all.each do |post|
      begin
        post_id = post.get_post_type_depre.id
        post.update_column("taxonomy_id", post_id)
        post_order = post.term_relationships.where("term_taxonomy_id = ?", post_id).first.term_order
        post.update_column("post_order", post_order)
      rescue
        # puts "**************** The following Post is invalid: #{post.inspect}"
      end
    end
  end
end

Version data entries

66 entries across 66 versions & 2 rubygems

Version Path
camaleon_cms-2.9.0 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.8.3 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.8.2 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.8.1 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.8.0 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.7.5 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.7.4 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.7.3 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.7.2 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.7.1 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.7.0 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.6.4 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.6.3 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.6.2 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.6.1 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.6.0.1 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.6.0 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.5.3.1 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.5.3 db/migrate/20150926095310_rename_column_posts.rb
camaleon_cms-2.5.2 db/migrate/20150926095310_rename_column_posts.rb