rails deploy - database not uploading - mysql

I'm working on my first rails app deploy and the database data from my local computer doesn't seem to be getting loaded into the database on the server when I deploy with capistrano. I'm not clear as to whether capistrano takes care of this or not. I have also tried running 'rake db:schema:load' from the /current release directory. Here's the log of what happens when I try to load the app (on the remote webserver) in a browser.
Started GET "/" for XX.XX.XX.XX at 2012-04-04 13:26:46 -0700
Processing by PagesController#home as HTML
Completed 500 Internal Server Error in 3ms
ActiveRecord::StatementInvalid (Mysql::Error: Table 'project.users' doesn't exist: SHOW FIELDS FROM `users`):
app/models/user.rb:61:in `authenticate_with_salt'
app/helpers/sessions_helper.rb:50:in `user_from_remember_token'
app/helpers/sessions_helper.rb:13:in `current_user'
app/helpers/sessions_helper.rb:17:in `signed_in?'
app/controllers/pages_controller.rb:5:in `home'
So the problem seems to be that the app loads, but the DB isn't populated with tables and data.
I'm sure I'm missing a relatively basic detail of the deployment process, but thus far it escapes me... Any help would be mucho appreciated! Thanks.

What does your Capfile look like?
Neither Rails nor Capistrano will copy data from your development environment to your deployment environment—db:migrate:* and db:schema:* only handle database structure. Before using rake db:schema:load make sure your development environment migrations have been run and your latest db/schema.rb is checked in to your repo.
If you want certain data to be in your database upon deployment look in db/seeds.rb. There are also many gems for seeding database data.

Related

Regenerate YML mapping issue in Symfony 2.4

Running a Symfony 2 project, I have recently made a change in my MYSQL database, and I would like to update my schema and model structure inside my symfony project so I can use the new items that are in it.
This is what I try to do from a running instance in production:
php app/console doctrine:mapping:import --force CoreBundle yml
Here is the error I get:
[PDOException] SQLSTATE[HY000] [2002] Connection timed out
Core/Bundle exists and was already mapped this way by the past
Also note that the server is up and running, doing exchanges with the database
I cannot find a place where to see a more detailed log. Tried to configure the config.yml to add logging for doctrine but it doesn't give me more infos
Thanks in advance
Since I didn't found the source of the problem, I just deployed a new symfony app, connected it to the database and then just generated orm + entities by following the same commands. After that I just copied the /Entity folder and /orm folder and replaced it on my production env. A bit messy but it worked

mysql not connecting to environment after ruby-2.2.2 upgade

I have just upgrade our legacy ruby app from ruby-1.9.3 to ruby-2.2.2. The app runs fine locally, I have successfully deployed it to our staging environment but for some reason it is now having issues connecting to mysql.
May 19 16:09:43 io-sbx-app-01-a3 rails[30750]: Reconnected to ActiveRecord
May 19 16:09:38 io-sbx-app-01-a3 rails[30738]: Verified ActiveRecord connections
May 19 16:09:43 io-sbx-app-01-a3 rails[30750]: Disconnected from ActiveRecord
Is there anything I need to consider with regards to connecting to mysql ? We currently use the mysql2 adapter
Here's what i can think of, with the information i have
1) see if the mysql service is up and running
2) see if the reconnect flag to true in database.yml.
3) in the staging environment, is the database service running in the same machine / on a different machine. If different machine, there might be some network related issues..
4) during your deployment process, do you re-start the mysql service. if not, it'd be good to try that..
5) you can check mysql.err and mysql.logs to see what happened from the database side of things..

rake db:migrate runs in development AWS Beanstalk

I'm new to Beanstalk. I've created a Rails application and set the database production configuration to use the environment variables hopefully provided by AWS. I'm using Mysql (mysql2 gem), and want to use RDS and Passenger (I have no preference there).
On my development environment I can run the rails application with my local Mysql (it is just a basic application I've created for experimentation).
I have added the passenger gem to Gemfile and bundled, but I'm using WEBBrick in development still.
The only thing I did not do by the book is that I did not use 'eb' but rather tried from the console. My application/environment failed to run as while "rake db:migrate" it still thinks I wanted it to connect to the local Mysql (I guess from the logs that it is not aware of RACK_ENV and hence uses 'development').
Any tip? I can of course try next the 'eb', yet would prefer to work with the console.
Regards,
Oren
In Elastic Beanstalk (both the web console and the cli), you can pass environnement variables. If you pass the RAKE_ENV variable, you will change your environnement.
After that you still need to pass your database parameters (db password, name, ...) which should not be hardcoded into the code.
Have you tried to run
bin/rake db:migrate RAILS_ENV=development
?
I got the same issue and that worked for me.
I recommend you enter to EC2 instance through this command "eb ssh" (The first time you need specified you .pem file, if you have not one you can create in IAM services) and check your logs for more information about yours error.
If you have problems when you are uploading your code (eb deploy) you have the log in this file: "/var/log/eb-activity.log" (Remember this file is in your EC2 instance)
If you have a problems with your app, you can read the logs in this files: "/var/app/support/logs/production.log" or "/var/app/support/logs/passenger.log"
Other recommedations is install EB CLI version 3. for manage your eb instance
http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install.html
I believed that Elastic Beanstalk will run 'rake db:migrate' by itself. Indeed it seems to try, but that is failing. I gave my bounty to 'Yahs Hef', even though I will only try this evening (UK). My disorientation with AWS caused me to forget this easy solution, of running the migration by myself. If this does not work by itself, I'll simplify the database configuration as possibile.

Team Foundation Server TFSConfig recover

When trying to restore my backuped TFSCollection via Administration Console (attach collection) the attachment fails. (NullReference Exception)
Are there any problems when restoring collections without the original configuration database?
The Collections is listed, but state doesn`t change from "offline", even when i tried to re-run the job.
When looking into [TFSCollection].[tbl_projects] via Management Studio I can see all projects.
When trying to restore the collection via
TFSConfig RegisterDB /sqlInstance:DataCenter\MSSQLServer /databaseName:DataCenter\MSSQLServer;Tfs_Configuration
I get the following error:
The following exception was caught while trying to validate the database: Keyword not supported: 'tfs_configuration;integrated security'.
Or when i run:
TFSConfig recover /ConfigurationDB:DataCenter\MSSQLServer;Tfs_Configuration /CollectionDB:DataCenter\MSSQLServer;Tfs_TFSCollection
The following error occurs:
TF246017: Team Foundation Server could not connect to the database. Verify that
the server that is hosting the database is operational, and that network problem
s are not blocking communication with the server.
Maybe I´ve run into some serious problem when installing TFS Service Pack 1.
What could i do to restore my TFS?
Even the import in my virtual enviroment fails. See the logfile.
If anyone had the same problem, take a look at http://support.microsoft.com/kb/2516423.
If you cant access your collections you could try.
TfsConfig updates /reapply
To start the TFS Job Agent you can run.
TfsServiceControl unquiesce
Or if the "Serviving" State doesnt change you could try this.
TfsConfig diagnose /scope:updates
TfsConfig updates /reapply
Hope this could help..

MySQL server has gone away: Rails on Passenger (Redmine)

I am making use of Redmine a web based software tracking tool, its perfect for my needs. However, I keep coming across this error in my production.log.
ActiveRecord::StatementInvalid
(Mysql::Error: MySQL server has gone
away: SELECT * FROM issue_relations
WHERE (issue_relations.issue_from_id
= 6) ): app/models/issue.rb:234:in after_save'
app/controllers/issues_controller.rb:196:in
edit'
When I add a ticket or update a ticket I get the below error and the above is recorded in my logs. It returns this via the browser after about 15 seconds. I have tried it several times, other areas of the app work fine.
Internal error
An error occurred on the page you were
trying to access. If you continue to
experience problems please contact
your redMine administrator for
assistance.
Back
I am using Ruby on Rails 2.3.8 on Phusion Passenger. Gem version 1.3.7. Active record 2.3.8. mysql (2.8.1 ruby x86-mingw32 x86-mswin32, 2.7.3 mswin32).
I am not a Ruby on Rails programmer and I am at loss on what else I can do to narrow this down. I had quick Google and found that as of rails 2.3 there is an option to reconnect so in my database.yml file I placed a reconnect true, but this didn't help!
Thanks all for any help
The list of usual suspects: http://dev.mysql.com/doc/refman/5.0/en/gone-away.html (all checkable on the MySQL-side of things).
Try putting the code from this Gist in a file in {rails application}/config/initializers/active_record_connections.rb: http://gist.github.com/238999
That said, this should probably not be happening in the first place - and if requests are taking 15 seconds to load, that also suggests that something else is going on. Can you share what appears in the logs before this error?