Rails 小数精度和小数位数

发布于 2024-08-04 18:30:29 字数 103 浏览 2 评论 0原文

我在 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红尘作伴 2024-08-11 18:30:29
change_column :table_name, :column_name, :type

will update the column's type.

参考: http://apidock.com/rails/ActiveRecord/ConnectionAdapters/SchemaStatements/change_column< /a>

change_column :table_name, :column_name, :type

will update the column's type.

Ref: http://apidock.com/rails/ActiveRecord/ConnectionAdapters/SchemaStatements/change_column

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文