Sha256: 8336b1ccbeaf312c7a7be5ed3f26351e506736d0bd0c2ed90576500307ff2c01
Contents?: true
Size: 1.5 KB
Versions: 11
Compression:
Stored size: 1.5 KB
Contents
class <%= migration_name %> < ActiveRecord::Migration def self.up create_content_table :<%= table_name %> do |t| <% for attribute in attributes -%> <%= case attribute.type when :category @category_type = class_name.titleize "t.belongs_to :category" when :attachment @attachment_section = class_name.titleize "t.belongs_to :attachment" + "\n t.integer :attachment_version" when :html "t.text :#{attribute.name}, :size => (64.kilobytes + 1)" else "t.#{attribute.type} :#{attribute.name}" end -%> <% end -%> end <% if @category_type %>unless CategoryType.named('<%= @category_type %>').exists? CategoryType.create!(:name => "<%= @category_type %>") end<% end %> <% if @attachment_section %>unless Section.with_path('/<%= file_name.pluralize %>').exists? Section.create!(:name => "<%= @attachment_section %>", :parent => Section.system.first, :path => '/<%= file_name.pluralize %>', :allow_groups=>:all) end<% end %> ContentType.create!(:name => "<%= class_name %>", :group_name => "<%= class_name %>") end def self.down ContentType.delete_all(['name = ?', '<%= class_name %>']) CategoryType.all(:conditions => ['name = ?', '<%= class_name.titleize %>']).each(&:destroy) #If you aren't creating a versioned table, be sure to comment this out. drop_table :<%= table_name.singularize %>_versions drop_table :<%= table_name %> end end
Version data entries
11 entries across 11 versions & 4 rubygems