Heroku + Rails、rake db migrate 在本地工作但在 heroku 上失败...
我正在像这样更改列上的比例...
change_column :options, :size, :decimal, :precision => 8, :scale => 8
它在本地工作,但是当运行它时,它会抛出错误...
PGError: ERROR: numeric field overflow
DETAIL: A field with precision 8, scale 8 must round to an absolute value less than 1.
: ALTER TABLE "options" ALTER COLUMN "size" TYPE decimal(8,8)
那么我如何在heroku上给出8的值比例和精度?
干杯。
I'm changing the scale on a column like so....
change_column :options, :size, :decimal, :precision => 8, :scale => 8
It's working locally, however when running it heroku it's throwing the error...
PGError: ERROR: numeric field overflow
DETAIL: A field with precision 8, scale 8 must round to an absolute value less than 1.
: ALTER TABLE "options" ALTER COLUMN "size" TYPE decimal(8,8)
So how do I give a value scale and precision of 8 on heroku?
Cheers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Postgres(在 Heroku 上运行的)如果精度和小数位数相同,则不需要两者同时存在。
精度是有效数字的总数
。小数位是 DP 右侧的数字位数。
因此通过设置8和8。这意味着总共必须是8位,并且DP右边有8位。这就是为什么会出现错误——不能有任何大于 1 的值。
如果您想要 DP 两侧各 8 位数字,请使用精度为 16,小数位数为 8。如果您只想要总共 8 位数字,则仅使用精度 = 8。
更多信息此处
Postgres (what is run on Heroku) shoudln't need both precision and scale if they are identical.
Precision is the total number of significant digits
Scale is the number of digits to the right of the DP.
Therefore by setting 8 and 8. This means that it must be 8 digits in total and 8 digits to the right of the DP. Hence why the error - you couldn't have anything greater than 1.
If you're wanting 8 digits either side of the DP use precision as 16 and scale as 8. If you're just wanting 8 total digits use precision = 8 only.
More info here