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
--