Reputation: 540
Having trouble setting up a AWS RDS for my Rails app running on Elastic Beanstalk. I followed the docs, but when it tries to run migrations, I get MySQL syntax errors. Pretty sure I don't have syntax errors because the migrations run fine locally and I successfully setup a staging and the errors are on the first line. I was thinking it might have to do with the security group blocking traffic, but I updated my inbound rules appropriately and still get the errors:
3306 tcp 173.8.166.54/32, sg-3221b354 <- RDs Security Group
80 tcp 0.0.0.0/0, ::/0, sg-3b31a75d
22 tcp 0.0.0.0/0
443 tcp 0.0.0.0/0
I have my environment variables set for the db. What am I missing?
The errors I'm getting: Occurs on the first line of the first migration
Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'json,
image
varchar(255),code
varchar(255),created_at
datetime NOT NULL,' at line 1: CREATE TABLEcoupons
(id
int AUTO_INCREMENT PRIMARY KEY,product
varchar(255),offer
varchar(255),size
varchar(255),description
varchar(255),info
json,image
varchar(255),code
varchar(255),created_at
datetime NOT NULL,updated_at
datetime NOT NULL) ENGINE=InnoDB /var/app/ondeck/db/migrate/20170725193230_create_coupons.rb:3:inchange' /opt/rubies/ruby-2.3.4/bin/bundle:22:in
load' /opt/rubies/ruby-2.3.4/bin/bundle:22:in<main>' ActiveRecord::StatementInvalid: Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'json,
imagevarchar(255),
codevarchar(255),
created_atdatetime NOT NULL,' at line 1: CREATE TABLE
coupons(
idint AUTO_INCREMENT PRIMARY KEY,
productvarchar(255),
offervarchar(255),
sizevarchar(255),
descriptionvarchar(255),
infojson,
imagevarchar(255),
codevarchar(255),
created_atdatetime NOT NULL,
updated_atdatetime NOT NULL) ENGINE=InnoDB /var/app/ondeck/db/migrate/20170725193230_create_coupons.rb:3:in
change' /opt/rubies/ruby-2.3.4/bin/bundle:22:inload' /opt/rubies/ruby-2.3.4/bin/bundle:22:in
' Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'json,image
varchar(255),code
varchar(255),created_at
datetime NOT NULL,' at line 1 /var/app/ondeck/db/migrate/20170725193230_create_coupons.rb:3:in `change'
migration in question:
class CreateCoupons < ActiveRecord::Migration[5.0]
def change
create_table :coupons do |t|
t.string :product
t.string :offer
t.string :size
t.string :description
t.json :info
t.string :image
t.string :code
t.timestamps
end
end
end
Upvotes: 0
Views: 196
Reputation: 540
Turns out the mysql version on the rds was wrong. AWS defaulted to 5.6. I upgraded to 5.7.17 and everything works.
Upvotes: 0