Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't use --clean flag with pg_restore #180

Merged
merged 1 commit into from
Jun 24, 2020
Merged

Don't use --clean flag with pg_restore #180

merged 1 commit into from
Jun 24, 2020

Conversation

croaky
Copy link
Contributor

@croaky croaky commented May 3, 2020

I noticed some output when restoring my database:

pg_restore: dropping TABLE geographic_areas
pg_restore: from TOC entry 266; 1259 16503 TABLE geographic_areas uf1mu7mdqgl0dj
pg_restore: error: could not execute query: ERROR:  table "geographic_areas" does not exist
Command was: DROP TABLE "public"."geographic_areas";

It looks like the source of the output was the --clean flag:

--clean
  Clean (drop) database objects before recreating them. (Unless
  --if-exists is used, this might generate some harmless error messages,
  if any objects were not present in the destination database.)

https://www.postgresql.org/docs/current/app-pgrestore.html

As the docs say, these errors are harmless, but noisy.

We don't need the --clean flag because the commands Parity runs were:

dropdb --if-exists "$db"
createdb "$db"
pg_restore tmp/latest.backup --verbose --clean --no-acl --no-owner --dbname "$db"

We've already dropped the whole database, so --clean is redundant.

I noticed some output when restoring my database:

```
pg_restore: dropping TABLE geographic_areas
pg_restore: from TOC entry 266; 1259 16503 TABLE geographic_areas uf1mu7mdqgl0dj
pg_restore: error: could not execute query: ERROR:  table "geographic_areas" does not exist
Command was: DROP TABLE "public"."geographic_areas";
```

It looks like the source of the output was the `--clean` flag:

```
--clean
  Clean (drop) database objects before recreating them. (Unless
  --if-exists is used, this might generate some harmless error messages,
  if any objects were not present in the destination database.)
```

https://www.postgresql.org/docs/current/app-pgrestore.html

As the docs say, these errors are harmless, but noisy.

We don't need the `--clean` flag because the commands Parity runs were:

```
dropdb --if-exists "$db"
createdb "$db"
pg_restore tmp/latest.backup --verbose --clean --no-acl --no-owner --dbname "$db"
```

We've already dropped the whole database, so `--clean` is redundant.
@geoffharcourt geoffharcourt merged commit 34aaf6b into thoughtbot:master Jun 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants