class CreateWorkstateIdentityTables < ActiveRecord::Migration def change #用户表 create_table :wa_id_users do |t| t.string :uaccount, :limit => 20, :null => false t.string :uname, :limit => 20, :null => false t.string :upsd, :limit => 255, :null => false t.string :salt, :limit => 100 t.string :status, :limit => 20, :null => false t.boolean :is_god, :null => false, :default => false t.integer :department_id, :null => false t.timestamps end add_index :wa_id_users, :uaccount #角色表 create_table :wa_id_roles do |t| t.string :name, :limit => 20, :null => false t.boolean :is_available, :null => false, :default => false t.timestamps end #用户角色表 create_table :wa_id_user_roles do |t| t.integer :user_id, :null => false t.integer :role_id, :null => false t.timestamps end add_index :wa_id_user_roles, :user_id add_index :wa_id_user_roles, :role_id #权限表 create_table :wa_id_permissions do |t| t.string :name, :limit => 20, :null => false t.string :url_type, :limit => 20, :null => false, :default => 'button'# menu,button,general t.string :url, :limit => 100 t.string :percode, :limit => 40 #权限代码字符串 t.string :url_path, :limit => 100 #页面链接 t.integer :parentid t.integer :m_parentid #菜单父节点 t.string :parentids, :limit => 100 #父结点id列表串 t.integer :sort, :null => false #排序 t.boolean :is_available, :null => false, :default => false #是否可用 t.timestamps end #角色权限表 create_table :wa_id_role_permissions do |t| t.integer :permission_id, :null => false t.integer :role_id, :null => false t.timestamps end add_index :wa_id_role_permissions, :permission_id add_index :wa_id_role_permissions, :role_id #用户token表 create_table :wa_id_user_tokens do |t| t.integer :user_id, :null => false t.string :token, :null => false t.integer :expire_time, :null => false, :default => 0 t.timestamps end add_index :wa_id_user_tokens, :user_id #部门表 create_table :wa_id_departments do |t| t.string :name, :limit => 20, :null => false t.timestamps end end #可新增~用户与主系统用户关系对应表 def self.down drop_table :wa_id_users drop_table :wa_id_roles drop_table :wa_id_permissions drop_table :wa_id_user_roles drop_table :wa_id_role_permissions drop_table :wa_id_user_tokens end end