syntax error, unexpected ‘\n’, expecting tCOLON2 or ‘[’ or ‘.’ in rails migrations, sqlite3
Are you getting the following error:
syntax error, unexpected '\n', expecting tCOLON2 or '[' or '.'
I was too, and it was a stupid mistake.
I had my migrations’ lines mixed up and containing a comma where there should not have been one.
Incorrect format:
class CreatePages < ActiveRecord::Migration
def self.up
create_table :pages do |t|
t.parent_id, :integer, :default => 0, :null => false
t.string :title
t.text :body
t.position, :integer
t.boolean :hidden, :default => false
t.main_nav, :boolean
t.top_nav, :boolean
t.footer_nav, :boolean
t.timestamps
end
end
def self.down
drop_table :pages
end
end
Correct format:
class CreatePages < ActiveRecord::Migration
def self.up
create_table :pages do |t|
t.integer :parent_id, :default => 0, :null => false
t.string :title
t.text :body
t.integer :position
t.boolean :hidden, :default => false
t.boolean :main_nav
t.boolean :top_nav
t.boolean :footer_nav
t.timestamps
end
end
def self.down
drop_table :pages
end
end
