From: Lee Doolan <rldoolanREMOVE@pacbell.net>
To: pgsql-admin@postgresql.org
Subject: database development
Date: 21 Oct 2001 15:52:17 -0700
Message-ID: <7oadyky5b2.fsf@stkitts.pacbell.net> (raw)
I am developing a website which has a postgres database as one
of its components. During development, it is not uncommon to
have to add a new attribute to a table, nor is it uncommon to
add an entirely new table to the schema when changes are made
to the system design --usually subsequent to a meeting
attended by the sales and mgt folks, but I shouldn't get
started on _that_.
In order to maintain the database schema, I started out by using
a script like this one which I kept stored in my source
repository:
SCRIPT> #!/bin/bash
SCRIPT> [. . .]
SCRIPT> ########################################################################
SCRIPT> # A S _ A N O N _ U S E R _ S E Q #
SCRIPT> ########################################################################
SCRIPT> # this sequence is incremented every time a new anonymous user is
SCRIPT> # created in the database
SCRIPT> echo "------------------------------------------------------------------------"
SCRIPT> echo "Creating as_anon_user_seq"
SCRIPT> psql -U "allseer" $ALLSEER_DBNAME <<-EOF
SCRIPT> create sequence as_anon_user_seq;
SCRIPT> EOF
SCRIPT> [. . .]
SCRIPT>
SCRIPT> ########################################################################
SCRIPT> # A S _ P R O J E C T S #
SCRIPT> ########################################################################
SCRIPT> echo "------------------------------------------------------------------------"
SCRIPT> echo "Creating as_projects"
SCRIPT> psql -U "allseer" $ALLSEER_DBNAME <<-EOF
SCRIPT>
SCRIPT> create table as_projects (
SCRIPT> proj_id serial PRIMARY KEY,
SCRIPT> proj_name text UNIQUE,
SCRIPT> proj_url text,
SCRIPT> proj_descr text,
SCRIPT>
SCRIPT> created timestamp,
SCRIPT> modified timestamp default now());
SCRIPT>
SCRIPT> grant all on as_projects to public;
SCRIPT>
SCRIPT> EOF
SCRIPT> [. . .]
Then, any time I wanted to change the schema, I would change the
script, rerun it and, voila! an improved database.
Somewhere along the line, I decided to stop maintaining the
script and to use pg_dump and pg_restore to maintain both the
schema and the data. This decision is one which I sometimes
regret but, hey, I could get back to the shell script form in
a few hours if I really wanted to.
My question is this: what techniques do other developers use in
these circumstances?
-lee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: rldoolanREMOVE@pacbell.net
Subject: Re: database development
In-Reply-To: <7oadyky5b2.fsf@stkitts.pacbell.net>
References: <7oadyky5b2.fsf@stkitts.pacbell.net>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox