Re: Template1 oops

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Alban Hertroys <alban(at)magproductions(dot)nl>
Cc: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Template1 oops
Date: 2006-09-13 14:29:05
Message-ID: 20060913142905.GA88961@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Sep 13, 2006 at 10:56:41AM +0200, Alban Hertroys wrote:
> I found an oops in one of our template1 databases; tables and stuff were
> apparently loaded into the wrong database (namely template1). I found
> this page describing a solution:
> http://techdocs.postgresql.org/techdocs/pgsqladventuresep1.php
>
> But, this looks kind of risky to me. I'd prefer not to put our running
> databases at risk.
>
> As an alternative approach, wouldn't dropping and recreating the public
> schema be a nice alternative? And in that case, what would be the right
> CREATE SCHEMA public command? I don't feel like messing this up ;)

The following should recreate the public schema:

CREATE SCHEMA public;
GRANT ALL ON SCHEMA public TO public;
COMMENT ON SCHEMA public IS 'Standard public schema';

You could practice by creating a test database from template0, then
use pg_dump to get a "before" dump of the test database, drop and
recreate the public schema, use pg_dump to get an "after" dump,
then compare the dumps with a command like "diff". The before and
after dumps should be identical.

When you're done messing with template1, you could dump it and
compare that dump to a dump of a database created from template0.
The comparison should show if you missed anything.

--
Michael Fuhr

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Fabi Avilés 2006-09-13 14:39:34 Problems with date configuration
Previous Message Matthieu Guamis 2006-09-13 13:50:58 Re: [RESOLVED] INSERT does not finish except if it is carried