rails十进制精度和小数位数 [英] rails decimal precision and scale

查看:96
本文介绍了rails十进制精度和小数位数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Rails应用程序中大约有30个表,我想更改一些小数列的精度和小数位数的大约6个表.您如何对已经存在的列执行此操作?您是否需要分别进行每个新迁移,还是可以一次完成所有迁移.

I have about 30 tables in a rails app and there are about 6 tables for which I would like to change the precision and scale of some of the decimal columns. How do you go about doing that for already existing columns? Do you need to do each new migration separately, or can they all be done at once.

推荐答案

change_column :table_name, :column_name, :type

将更新列的类型.

引用: http://apidock.com/rails/ActiveRecord/ConnectionAdapters/SchemaStatements /change_column

这篇关于rails十进制精度和小数位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆