Ruby on rails Heroku,Rails:PG::SyntaxError

Ruby on rails Heroku,Rails:PG::SyntaxError,ruby-on-rails,ruby,postgresql,heroku,heroku-postgres,Ruby On Rails,Ruby,Postgresql,Heroku,Heroku Postgres,在heroku上的my Rails 5.1应用程序中加载架构时,会引发以下异常: ActiveRecord::StatementInvalid:PG::SyntaxerError:ERROR:在“引擎”处或附近出现语法错误 第1行:…estamp NOT NULL,“在”timestamp NOT NULL“处更新”ENGINE=Inn 详细信息: 痕迹 config/database.yml 旁注:我知道Heroku使用PostgreSQL数据库,但在将开发和测试数据库设置为MySQL之

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

ActiveRecord::StatementInvalid:PG::SyntaxerError:ERROR:在“引擎”处或附近出现语法错误 第1行:…estamp NOT NULL,“在”timestamp NOT NULL“处更新”ENGINE=Inn


详细信息:

痕迹


config/database.yml


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



我做错了什么?

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

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

heroku run rake db:migrate

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

看看您的迁移-它们是否有以下选项:
选项:“ENGINE=InnoDB DEFAULT CHARSET=utf8”
?移除这些并将其推回到Heroku可能会解决问题


更多细节 这可能是Rails 5的新特性,这使得迁移很难保持数据库无关性。这些选项针对MySQL,并指定应使用
InnoDB
存储引擎

当你推到Heroku时,你的
数据库.yml
会自动更新为使用Postgres。但是,您的迁移未受影响,引擎参数对Postgres无效,并导致错误


这也可能会影响您的
模式.rb

很高兴知道。我以前看过我的迁移,它们不包含任何特定的选项。
# # 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 run rake db:migrate