Sha256: 227de8d10be614098d4b5c26214cf468acc9f50d0589844465e3ba7582d76ce0
Contents?: true
Size: 817 Bytes
Versions: 2
Compression:
Stored size: 817 Bytes
Contents
class AddPageAttachmentsFields < ActiveRecord::Migration def self.up add_column :page_attachments, :title, :string add_column :page_attachments, :description, :string add_column :page_attachments, :position, :integer pages_with_attachments = PageAttachment.find_by_sql('select page_id from page_attachments where page_id is not null group by page_id') pages_with_attachments.each do |pa| attaches = PageAttachment.find(:all, :conditions => ['page_id = ?',pa.page_id], :order => :id) i=1 attaches.each do |attach| attach.position = i attach.save i = i + 1 end end end def self.down remove_column :page_attachments, :title remove_column :page_attachments, :description remove_column :page_attachments, :position end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
radiant-page_attachments-extension-1.0.2 | db/migrate/002_add_page_attachments_fields.rb |
radiant-page_attachments-extension-1.0.0 | db/migrate/002_add_page_attachments_fields.rb |