Development, test and production - what for?

Could some one explain why there is three different possible databases
â?? development, test and production? What’s the difference? How do you
switch between them?

Hi Pal,

you are switching between them by using a different environment by
stating
the environment you want to use in environment.rb or by telling your
application server to do so (for example the mongrel by mongrel_rails
start
-e production.

The environment is what is the ‘headline’ above the configurations. A
database-config comes with three predefined environments ‘development’,
‘test’ and ‘production’ but you might configure some others for
yourself.

The test environment is special because integration tests with fixtures
which represent test data will be performed on a special test database.
The
advantage should be obvious. On the development database you should
perform
your development. This might be an physically different machine from
your
production database or at least decoupled as another database on the
same
machine. This way you could release stable versions to production and go
online with it and destroy nothing on your production data while you are
evolving on the development db.

Said shortly: As in many cases rails forces you to do the right thing.

Cheers,
Jan

Jan P. wrote:

Well explained. Thank you (and Tom). The database names says it all, I
know. :slight_smile:

Perhaps I should have asked how they are “managed”. What happens when
using the rake to create the db? Will that add or change in them all? (I
could also try this so you don’t have to answer, if you don’t feel like
it)

On Aug 22, 2006, at 1:46 AM, Pål Bergström wrote:

Could some one explain why there is three different possible databases
? development, test and production? What’s the difference? How do you
switch between them?

Development is for development.

Test is for testing.

Production is for… :slight_smile:

They are switched on via ENV[‘RAILS_ENV’]

Also switched on are the config/environments/* files.

You can have more environments if you choose.

Development and Testing are related in that when running tests, the
development DB structure is moved into testing so that tests get run
against the current development DB structure.

All of this structure is put in place to allow you to pre-define this
information and not have to change code when it’s used in different
environments.


– Tom M.

On Aug 22, 2006, at 3:45 AM, Pål Bergström wrote:

But how then do you use the others? Will a rake command automatically
add the stuff from development to production, when ready? Or how
does it
work?

Migrations are technology sufficiently advanced as to appear to be
magic. :slight_smile:


– Tom M.

Pål Bergström wrote:

What happens when
using the rake to create the db? Will that add or change in them all? (I
could also try this so you don’t have to answer, if you don’t feel like
it)

And no. It doesn’t. Stupid question I guess. A change in development
shouldn’t affect production mode instantly.

But how then do you use the others? Will a rake command automatically
add the stuff from development to production, when ready? Or how does it
work?