0

I have a Rails 3.2 application and I have some issues on the production side:

I have a model 'Poject' and did a migration to add a string for 'description'. running rake db:migrate works fine on my developer machine like all the times. But when I do a cap deploy and cap migrate on the production server I cannot update my project models which where already in the database. Only new ones work fine. I'm using postgres 9.1

I don't know what's the issue here since its working fine on my local machine.

Regards

Oliver

  • 1
    Have you restarted the rails server? Probably it'll fix this issue – techvineet Sep 04 '13 at 12:47
  • Did you also add a presence validation for the `description`? Fire up a console on your production server, try to update an existing project and if it fails take a look at `project.errors`. – doctororange Sep 04 '13 at 12:56
  • @techvineet Yes I did... And its working fine when I create a new Project model. – user2258116 Sep 04 '13 at 12:58
  • what does `project.errors` give you after you attempt to update in the console? – usha Sep 04 '13 at 13:00
  • yes I did a presence validation. firing up the console give me this error: database configuration does not specify adapter. do I need to define a development mode in production? – user2258116 Sep 04 '13 at 13:09
  • @user2258116: when starting up in production - you need to use the 'production' mode - something like this should work for you: `bundle exec rails c production` – PinnyM Sep 04 '13 at 13:11
  • copy and paste you database.yml here. – Sachin Singh Sep 04 '13 at 13:11
  • It looks like the validation was the problem: validating the presence of a newly added field creates the problem for the existing records. thanks. – user2258116 Sep 04 '13 at 13:14
  • @PinnyM: bundle exec rails c production works fine. Thanks – user2258116 Sep 04 '13 at 13:17

2 Answers2

0

I think what you are looking for is cap deploy:migrate.

Run the migrate rake task. By default, it runs this in most recently deployed
version of the app...

You can read more about it here: https://github.com/capistrano/capistrano/wiki/Capistrano-Tasks

Also make sure you are using the right environment while using capistrano

Joe
  • 2,987
  • 15
  • 24
0

Thank you, I did run the cap deploy:migrate task. But here the problem was that I was validating the existence of a newly created field and this caused the trouble with the records which where already in the database.

thanks.