Обсуждение: Drop database/create database broken in 7.4?

Поиск
Список
Период
Сортировка

Drop database/create database broken in 7.4?

От
"John Wells"
Дата:
Guys,

I'm running PG 7.4 on Ubuntu Breezy for Ruby on Rails development. One of
the things I ofter have to do is rebuild the database...for which I have a
script that I've created to do it in one step.

I've noticed some oddities. The script connects to template1, drops the
target database, creates the target database, and the rebuilds the tables.
However, two specific tables and sequences are not dropped, although  the
drop command completes successfully.

For example, here's the error reproduced manually:

dailystatus=> \d
              List of relations
 Schema |      Name       |   Type   | Owner
--------+-----------------+----------+--------
 public | garages         | table    | wellsj
 public | garages_id_seq  | sequence | wellsj
 public | trucks          | table    | wellsj
 public | trucks_id_seq   | sequence | wellsj
 public | sites           | table    | wellsj
 public | sites_id_seq    | sequence | wellsj
 public | statuses        | table    | wellsj
 public | statuses_id_seq | sequence | wellsj
 public | users           | table    | wellsj
 public | users_id_seq    | sequence | wellsj
(10 rows)

dailystatus=> \c template1
You are now connected to database "template1".
template1=> drop database dailystatus;
DROP DATABASE
template1=> create database dailystatus;
CREATE DATABASE
template1=> \c dailystatus
You are now connected to database "dailystatus".
dailystatus=> \d
             List of relations
 Schema |     Name     |   Type   | Owner
--------+--------------+----------+--------
 public | sites        | table    | wellsj
 public | sites_id_seq | sequence | wellsj
 public | users        | table    | wellsj
 public | users_id_seq | sequence | wellsj
(4 rows)

dailystatus=>

Anyone know what might be happening? I'm at a loss.

Thanks!
John



Re: Drop database/create database broken in 7.4?

От
Scott Marlowe
Дата:
On Thu, 2006-01-05 at 13:09, John Wells wrote:
> Guys,
>
> I'm running PG 7.4 on Ubuntu Breezy for Ruby on Rails development. One of
> the things I ofter have to do is rebuild the database...for which I have a
> script that I've created to do it in one step.
>
> I've noticed some oddities. The script connects to template1, drops the
> target database, creates the target database, and the rebuilds the tables.
> However, two specific tables and sequences are not dropped, although  the
> drop command completes successfully.
>
> For example, here's the error reproduced manually:
>
> dailystatus=> \d
>               List of relations
>  Schema |      Name       |   Type   | Owner
> --------+-----------------+----------+--------
>  public | garages         | table    | wellsj
>  public | garages_id_seq  | sequence | wellsj
>  public | trucks          | table    | wellsj
>  public | trucks_id_seq   | sequence | wellsj
>  public | sites           | table    | wellsj
>  public | sites_id_seq    | sequence | wellsj
>  public | statuses        | table    | wellsj
>  public | statuses_id_seq | sequence | wellsj
>  public | users           | table    | wellsj
>  public | users_id_seq    | sequence | wellsj
> (10 rows)
>
> dailystatus=> \c template1
> You are now connected to database "template1".
> template1=> drop database dailystatus;
> DROP DATABASE
> template1=> create database dailystatus;
> CREATE DATABASE
> template1=> \c dailystatus
> You are now connected to database "dailystatus".
> dailystatus=> \d
>              List of relations
>  Schema |     Name     |   Type   | Owner
> --------+--------------+----------+--------
>  public | sites        | table    | wellsj
>  public | sites_id_seq | sequence | wellsj
>  public | users        | table    | wellsj
>  public | users_id_seq | sequence | wellsj
> (4 rows)
>
> dailystatus=>
>
> Anyone know what might be happening? I'm at a loss.


Yep, somewhere along the lines you accidentally created those tables in
template1

Re: Drop database/create database broken in 7.4?

От
"Jim Buttafuoco"
Дата:
John

check to see if the objects are in the template1 database which just gets copied 100% to the target db.

Jim



---------- Original Message -----------
From: "John Wells" <jb@sourceillustrated.com>
To: pgsql-general@postgresql.org
Sent: Thu, 5 Jan 2006 14:09:02 -0500 (EST)
Subject: [GENERAL] Drop database/create database broken in 7.4?

> Guys,
>
> I'm running PG 7.4 on Ubuntu Breezy for Ruby on Rails development. One of
> the things I ofter have to do is rebuild the database...for which I have a
> script that I've created to do it in one step.
>
> I've noticed some oddities. The script connects to template1, drops the
> target database, creates the target database, and the rebuilds the tables.
> However, two specific tables and sequences are not dropped, although  the
> drop command completes successfully.
>
> For example, here's the error reproduced manually:
>
> dailystatus=> \d
>               List of relations
>  Schema |      Name       |   Type   | Owner
> --------+-----------------+----------+--------
>  public | garages         | table    | wellsj
>  public | garages_id_seq  | sequence | wellsj
>  public | trucks          | table    | wellsj
>  public | trucks_id_seq   | sequence | wellsj
>  public | sites           | table    | wellsj
>  public | sites_id_seq    | sequence | wellsj
>  public | statuses        | table    | wellsj
>  public | statuses_id_seq | sequence | wellsj
>  public | users           | table    | wellsj
>  public | users_id_seq    | sequence | wellsj
> (10 rows)
>
> dailystatus=> \c template1
> You are now connected to database "template1".
> template1=> drop database dailystatus;
> DROP DATABASE
> template1=> create database dailystatus;
> CREATE DATABASE
> template1=> \c dailystatus
> You are now connected to database "dailystatus".
> dailystatus=> \d
>              List of relations
>  Schema |     Name     |   Type   | Owner
> --------+--------------+----------+--------
>  public | sites        | table    | wellsj
>  public | sites_id_seq | sequence | wellsj
>  public | users        | table    | wellsj
>  public | users_id_seq | sequence | wellsj
> (4 rows)
>
> dailystatus=>
>
> Anyone know what might be happening? I'm at a loss.
>
> Thanks!
> John
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Have you searched our list archives?
>
>                http://archives.postgresql.org
------- End of Original Message -------


Re: Drop database/create database broken in 7.4?

От
Joe Conway
Дата:
John Wells wrote:
>
> I've noticed some oddities. The script connects to template1, drops the
> target database, creates the target database, and the rebuilds the tables.
> However, two specific tables and sequences are not dropped, although  the
> drop command completes successfully.

> Anyone know what might be happening? I'm at a loss.
>

Sounds like those two tables were created in the template database at
some point.

HTH,

Joe

Re: Drop database/create database broken in 7.4?

От
"John Wells"
Дата:
Scott Marlowe said:
> Yep, somewhere along the lines you accidentally created those tables in
> template1

<sheepish grin> yep, sorry guys. I need more sleep </sheepish grin>

Thanks!
John


Re: Drop database/create database broken in 7.4?

От
Scott Marlowe
Дата:
On Thu, 2006-01-05 at 13:30, John Wells wrote:
> Scott Marlowe said:
> > Yep, somewhere along the lines you accidentally created those tables in
> > template1
>
> <sheepish grin> yep, sorry guys. I need more sleep </sheepish grin>

Hey, how do you think we all recognized that mistake so quickly.  We've
all done it before. :)