jon*_*hue 3 ruby postgresql ruby-on-rails heroku heroku-postgres
在heroku上的Rails 5.1应用程序中加载模式时,会引发以下异常:
ActiveRecord :: StatementInvalid:PG :: SyntaxError:ERROR:"ENGINE"第1行或附近的语法错误第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!
配置/ 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.您需要添加适当的插件.