10.megabytes Heroku 给我这个 -6ren">
gpt4 book ai didi

ruby-on-rails - Heroku 迁移 : type modifier is not allowed for type "bytea"

转载 作者:行者123 更新时间:2023-11-29 11:18:47 29 4
gpt4 key购买 nike

我在 Heroku 上运行一些迁移,我遇到了这个问题。我在我的一个迁移中有这一行来创建一个新表:

t.binary :file, :limit => 10.megabytes

Heroku 给我这个 PostgreSQL 错误:

An error has occurred, this and all later migrations canceled:

PGError: ERROR: type modifier is not allowed for type "bytea"
LINE 1: ..."file" bytea(10485760)...
^
: CREATE TABLE "files" ("id" serial primary key, "file" bytea(10485760), "created_at" timestamp, "updated_at" timestamp)

我怎样才能改变我的迁移以使其与 MySQL 和 Postgre 兼容?

最佳答案

来自 Heroku 的文档:

二进制字段限制

原因:PostgreSQL 不限制二进制字段。任何使用 :limit 选项添加 :binary 字段的迁移都会引发语法错误。

解决方案:如果可能,省略二进制字段的 :limit — 或者在运行数据库之前测试它。

关于ruby-on-rails - Heroku 迁移 : type modifier is not allowed for type "bytea",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4976368/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com