stripe / pg-schema-diff

Go library for diffing Postgres schemas and generating SQL migrations
MIT License
270 stars 20 forks source link

Exclude schemas owned by extensions #127

Closed bplunkett-stripe closed 2 months ago

bplunkett-stripe commented 2 months ago

Description

Exclude schemas owned by extensions.

Example:

pg_repack creates a schema called pg_repack. Let's say the user's model.sql removes the CREATE EXTENSION pg_repack line. This will generate two statements:

  1. Drop extension pg_repack
  2. Drop schema pg_repack

The first line drops the pg_repack schema as well because it is owned by the extension, causing the second line to fail. As a result, we should stop generating statements for schemas owned by extensions, just like we do with other schema objects.

Motivation

Bug fix

Testing

There are few extensions that actually create extensions. One is pg_repack but it doesn't come with the default set of extensions in postgres-contrib. As a result, I just tested locally by creating pg_repack an