# encoding:utf-8
class CreateBindUsers < ActiveRecord::Migration
  def up
    #用户绑定记录
    create_table :bind_users do |t|
      #用户ID
      t.column :wx_uid, :integer, :null=>false
      #老用户编号
      t.column :user_no, :string
      #昵称
      t.column :nickname,:string
      #备注
      t.column :remark,:string
      t.timestamps
    end
    #系统会员表
    create_table :sys_users do |t|
      #邀请人ID
      t.column :invite_id, :integer, :null=>false
      #会员编号
      t.column :user_no, :string, :limit=>128
      #邀请人编号
      t.column :invite_no,:string, :limit=>128
      #等级
      t.column :dengji,:string, :limit=>128
      #群主标记
      t.column :show_invite_mode, :boolean, :default=>0
      #群主
      t.column :rank, :integer, :null=>false
      t.timestamps
    end
    add_index :bind_users, :wx_uid
    add_index :sys_users, :invite_id
    add_column :wx_users, :user_no,:string,:limit => 128
  end

  def down
    drop_table :bind_users
    drop_table :sys_users
    remove_column :wx_users, :user_no
  end

end
