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
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
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.
Related
I created an app on one Mac. It runs fine. I checked it into GitHub and pushed it to the remote. I then go to another mac and do git fetch origin,
followed by git reset --hard. I follow this with bundle install, then rails db:reset, and rails db:migrate. I then try to register exactly as I did on the other mac. I get:
ActionController::InvalidAuthenticityToken in Devise::RegistrationsController#create
I'm afraid I'm having a problem with moving the code between machines. They both have exactly the same version of rvm, rails, rbenv, etc. It doesn't seem like it should be this flaky. What other steps are necessary?
I realized after ready the above answer from Vishal, that my environment was not persisted in github. I realize now that I have to check out the code, then run bundle install, then rake db:create, then rake db:migrate, then finally rails s, if I got not errors in the previous. When I did this, I found I had a different rails version on the target computer than I did on the source computer.
I now use a script 'laptop' which I located at: https://github.com/monfresh/laptop.git
This works on a mac ( I use macs pretty exclusively ) and sets up the same environment on each one where it is run. After doing this, I find I can check in codes on one mac, then check them out on another, run laptop, then my rails apps work correctly.
I'm using IntelliJ Idea with the Rubymine plugin, and Heroku plugin, and I'm a bit stumped when it comes to pushing an app to Heroku. I can set it up and actually push the app: off it goes, and launches successfully. But even before I did that I was expecting it to fail because I couldn't find anyway of getting it to do a db:migrate. And so it proved: the app is launched but of course it fails pretty much immediately because there's no DB.
I've looked on the forums, google etc but nothing. Is this something that can only be done from the command line? I would have expected an IDE to be what it says on the tin: Integrated. So I feel I'm missing something. The Run configuration works as I've said, and the Heroku log has no errors, but I need a way to tell it to run the db:migrate before launching.
Any ideas?
The answer is that it is something that it doesn't do - confirmed by IntelliJ. So in this case, one needs to push the app to Heroku, drop to the command line and run the migration there: heroku run rake db:migrate.
I raised a feature request so this may be something that can be added in the future.
I haven't figured out how to do this automatically as part of the RubyMine/JetBrains Heroku Plugin. But you can cobble this together from other sources.
Start with this gist that creates rake tasks for Heroku operations provided by this answer to a similar question:
Then create a new run configurations for each Rake task that you will be using at some point. You will need at minimum push and migrate. But the other tasks might interest you.
Then create a new compound run configuration calling the Rake tasks you created in step 2 in the correct order.
Step 2 and 3 can be consolidated by creating one rake task for migration, and adding a before rake task to push. But that's kind of counter intuitive.
Note: that this approach does require you to have the Heroku CLI installed and configured with valid credentials.
6 months back I wrote a rails app (craigslist scraper) and all of the code was pushed to github and then deployed to heroku. Since this time I got a new laptop and am getting back into learning code. I am trying to get the same app running locally on my machine but am getting an error that no DB is connected (( Rails.application.database_configuration: Could not load database configuration. No such file )) how can I download the DB file from GitHub or get the DB going again and run a fresh scrape? thanks in advance!
You need to run.
rake db:create db:migrate
This will create the database from your database.yml file, then run the migrations.
I have successfully managed to set up a VPS production server (Ubuntu 10.04 LTS) from the excellent Railscasts episode. It's an "internal" server (not live yet), so I've been building my app locally and doing a cap deploy at regular intervals to check that things are running smoothly.
However, what I'd like to do now is delete all records on the production server (as I've just been testing stuff) - that is, to start with a completely empty database for when the site actually goes live to the public.
Obviously, I can do this locally by running something like rake db:reset, but how do I do this on the production server? Should I be adding some code to my deploy.rb file?
I'm a bit of a noob at this, but I've been unable to find anything via a Google search.
** EDIT ** Oh, and obviously this is a one-off - once things go live, I'll remove any code which deletes records!
You can ssh into the server and run any rake command from the application directory. You could create a Capistrano task just to run this one rake task, but since this task is obscenely dangerous with any real system I would not recommend it. The last thing you would want is to accidentally run it.
I've got a fair bit of experience with Ruby on Rails, and I'm taking over development on an existing project created in Grails. The previous developer claims that anyone with Rails experience should be able to do just fine, but I'm banging my head against the wall...
I have the Grails environment correctly configured, and the app can connect to my database. If I were in a RoR project, I know I would just need to run 'rake db:create && rake db:migrate', and I'd be ready to go.
Is there a grails equivalent to bootstrap the database schema?
The default setting in DataSource.groovy of dbCreate = 'create-drop' will create the database tables after dropping previous tables. This works fine for initial development and ok while you're making rapid changes, but once things stabilize somewhat (and at the latest when you're going to production) install the http://grails.org/plugin/database-migration plugin to do proper migrations.
The DSL will look familiar to a Rails developer, and there are convenient scripts that auto-generate migration scripts for you.