In my rails app I have a model Events. It has several columns which were created through following this guide https://devcenter.heroku.com/articles/export-from-heroku-postgres and then performing rake db:schema:dump.
Now I want to add some new columns to the Event model. I tried editing schema.rb and restarting the app but that didn’t seem to work. Anyone know the proper way to proceed?
—-Edit——-
Specifically I added this line to the Event model in schema.rb.
t.datetime "date_time"
When I click the link to add a event in the rails app I receive this error:
undefined method `date_time' for #<Event:0x007fdb59a87118>
The
schema.rbfile is a representation of the current state of the database schema, it is written by the database migration process, not read.If you want to add a new column, create a migration:
Then add your columns:
Everything except the
add_columnshould be there already. Once you have your migration, do arake db:migrateand you’re done. Now you should see some changes in yourschema.rb.See the Ruby on Rails Migration Guide for further details and different ways to build your migrations.