Rails--bundle exec rake db:migrate

--新建表:

def up
  create_table :[TABLE_NAME] do |t|
    t.column :[NUM], :integer
    t.column :[NAME], :string
    t.column :[TIME], :timestamp
    t.column :[ACTIVE], :boolean, :default => true
    # 不推荐,用task rake
    execute <<-SQL
      [SQL-1];
      [SQL-2];
    SQL
    
    t.timestamps
  end
  
  add_index :location_properties, :[NUM]
  add_index :location_properties, :[NAME] , :unique => true
  
end

def down
  drop_table :[TABLE_NAME]
end

 

--

 

posted @ 2016-09-28 20:33  盖瑞  阅读(291)  评论(0编辑  收藏  举报