gpt4 book ai didi

ruby-on-rails - Heroku、Rails:PG::SyntaxError

转载 作者:数据小太阳 更新时间:2023-10-29 07:49:20 25 4
gpt4 key购买 nike

在 heroku 上的 Rails 5.1 应用程序中加载架构时,引发了以下异常:

ActiveRecord::StatementInvalid: PG::SyntaxError: ERROR: syntax error at or near "ENGINE" LINE 1: ...estamp NOT NULL, "updated_at" timestamp NOT NULL) ENGINE=Inn...


详细信息:

追踪

-- create_table("ads_dashboard_campaigns", {:force=>:cascade, :options=>"ENGINE=InnoDB DEFAULT CHARSET=utf8"})
(5.0ms) DROP TABLE IF EXISTS "ads_dashboard_campaigns" CASCADE
(7.3ms) CREATE TABLE "ads_dashboard_campaigns" ("id" bigserial primary key, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL) ENGINE=InnoDB DEFAULT CHARSET=utf8
rails aborted!


config/database.yml

# # SQLite version 3.x
# # gem install sqlite3-ruby (not necessary on OS X Leopard)
# development:
# adapter: sqlite3
# database: db/development.sqlite3
# pool: 5
# timeout: 5000

# # Warning: The database defined as "test" will be erased and
# # re-generated from your development database when you run "rake".
# # Do not set this db to the same as development or production.
# test:
# adapter: sqlite3
# database: db/test.sqlite3
# pool: 5
# timeout: 5000

production:
adapter: sqlite3
database: db/production.sqlite3
pool: 5
timeout: 5000


# Custom stuff
development:
adapter: mysql2
encoding: utf8
pool: 5
database: slooob_development
username: root
password: 0402Jonas
port: 3306

test:
adapter: mysql2
encoding: utf8
pool: 5
database: slooob_test
username: root
password: 0402Jonas
port: 3306

旁注:我知道 Heroku 使用 PostgreSQL 数据库,但在将开发和测试数据库设置为 MySQL 之前,使用默认设置进行生产已经有效。我还尝试将适配器设置为 postgresql


我做错了什么?

最佳答案

您的数据库模式是在 Mysql 数据库上生成的,并且包含 Mysql 特定的选项。在您的情况下,它是 ENGINE 选项。我不确定它是自动生成的还是您手动将这些选项添加到迁移中。

尝试运行迁移而不是加载架构:

heroku run rake db:migrate

您还可以在 Heroku 上使用 Mysql。您需要添加适当的插件。

关于ruby-on-rails - Heroku、Rails:PG::SyntaxError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42736529/

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