On Aug 5, 2007, at 18:58 , Perry Smith wrote:
I find it odd that you are resistant to the idea. To me, the advantages are clear if it can be done without a tremendous amount of work. Why horse around with the environment variables to set such things as password, call sh, just to call pg_dump.
My resistance was to the idea that creating a connection through ActiveRecord was preferable to a system call.
I believe that pg_dump/psql are only required if you're using config.active_record.schema_format = :sql. (I may be mistaken, as I exclusively use schema_format = :sql so any other possible dependents are already satisfied.)
When using config.active_record.schema_format = :sql, pg_dump and psql pretty much need to be in your path. And if psql is already in your path, psql can be used with the -c flag to run arbitrary commands (such as CREATE/DROP DATABASE and also CREATE ROLE), so createdb and dropdb are not really necessary for most purposes. Of course, you still need a database to connect to. Personally, I don't want to put postgres/template1 connection information in database.yml for security reasons: these commands are not run very often and a great way to keep information secure is to not have it available. Personally I wish Rails did not include database.yml by default as I think it's much too easy to load it into an SCM repository. I use a custom rake task to set up the Rails application to take care of this as well as other details, including database and role creation. (This is especially helpful for running tests.)
If you're not using config.active_record.schema_format = :sql, then perhaps pg_dump and psql are not required, and they aren't necessarily in your path. In that case it might make sense to use ActiveRecord for CREATE/DROP DATABASE as you aren't necessarily going to have psql otherwise in your path. However, in this case in my opinion it's better for the above-mentioned security reasons not to.
Michael Glaesemann grzm seespotcode net ---------------------------(end of broadcast)--------------------------- TIP 3: Have you checked our extensive FAQ? http://www.postgresql.org/docs/faq