# encoding:utf-8

#前端各种栏目、频道配置
class CreatePlatformCategories < ActiveRecord::Migration
  def up
    create_table :platform_categories do |t|
      #名称
      t.string  :name,  :default => '', :null => false, :limit => 10
      #排序
      t.integer :position, :default => 1, :null => false
      t.string  :ancestry,  :limit => 20, :default => ''
      #配置不同的平台，录入产品时init，微信端首页wx_home
      t.column :platform, :string, :limit => 20, :default => '', :null => false
      t.column :url, :string, :limit => 4096, :default => '',:null => false
      #内部链接：0，外部链接：1 
      t.tinyint :url_type, :default => 0
      t.string :cover
      t.column :state, :boolean, :default => true,  :null => false
      #备注
      t.column :remark, :string, :limit => 225, :default => ''
      #如果是推单品的，则记录产品ID
      t.column :product_id, :integer, :default => 0
      
    end
    add_index :platform_categories, :position
    add_index :platform_categories, :ancestry
    add_index :platform_categories, :platform    
  end

  def down
    drop_table :platform_categories
  end
end