Received: from news.tht.net (news.hub.org [216.126.91.242]) by postgresql.org (8.11.3/8.11.4) with ESMTP id f9MGbkP28005 for ; Mon, 22 Oct 2001 12:37:46 -0400 (EDT) (envelope-from news@news.tht.net) Received: (from news@localhost) by news.tht.net (8.11.4/8.11.4) id f9LMqZ207637 for pgsql-admin@postgresql.org; Sun, 21 Oct 2001 18:52:35 -0400 (EDT) (envelope-from news) From: Lee Doolan X-Newsgroups: comp.databases.postgresql.admin Subject: database development Date: 21 Oct 2001 15:52:17 -0700 Organization: [...] Lines: 65 Message-ID: <7oadyky5b2.fsf@stkitts.pacbell.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: scrappy@hub.org User-Agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/20.7 To: pgsql-admin@postgresql.org X-Archive-Number: 200110/217 X-Sequence-Number: 2461 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