How do you copy over a development database to production?

Personally, I just export/import the database via sql admin. Much simpler to manage.

I use mongrel_rails cluster and apache, and subversion and capistrano. One day soon I will look into doing all this with scripts and / or subversion / capistrano, but for now, this is not too bad:

On my production box:

remove the production database (I keep backups on the development side, which is where all my changes take place):

mysql > drop database projectname_production

create a new empty production database, so I can import new sql into it in a moment:

mysql > create database projectname_production

Then, on development my development box:

dump out the entire development database into an sql file:

mysqldump -u mysql -p projectname_development > projectname_production.sql

copy entire database to production machine

on production machine: mongrel_rails cluster::stop apachectl stop

mysql -u root -p projectname_production < projectname_production.sql

mongrel_rails cluster::start apachectl start

That's what I do --

Charlie

nextpulse wrote:

Hi Bob,

this may be a silly answer, but just putting it across,

change your database.yml file entries like:

exchange your username, password, database, host etc, in production to test then run the corresponding rake task. (i don't remember the task, may be "rake clone:db_struture" or "rake test:db:prepare"

Note: doing this will copy all your schema but it may not copy the constraints you defined on those database objects.