diff --git a/internal/db/diff/migra.go b/internal/db/diff/migra.go index f79c4ae16..cbed35f4a 100644 --- a/internal/db/diff/migra.go +++ b/internal/db/diff/migra.go @@ -5,6 +5,7 @@ import ( "context" _ "embed" "strings" + "regexp" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" @@ -147,5 +148,12 @@ EOF ); err != nil && !strings.HasPrefix(stderr.String(), "main worker has been destroyed") { return "", errors.Errorf("error diffing schema: %w:\n%s", err, stderr.String()) } - return out.String(), nil + // TODO: migra does not support ignoring functions yet + return filterFunctionBody(out.String()), nil +} + +var grantFuncPattern = regexp.MustCompile(`(?s)CREATE OR REPLACE FUNCTION extensions.grant_pg_(cron|net)_access.+?END;\$function\$;`) + +func filterFunctionBody(diff string) string { + return grantFuncPattern.ReplaceAllString(diff, "") } diff --git a/internal/db/pull/pull.go b/internal/db/pull/pull.go index feffe2ce2..ccf0a5728 100644 --- a/internal/db/pull/pull.go +++ b/internal/db/pull/pull.go @@ -28,7 +28,7 @@ var ( errMissing = errors.New("No migrations found") errInSync = errors.New("No schema changes found") errConflict = errors.Errorf("The remote database's migration history does not match local files in %s directory.", utils.MigrationsDir) - managedSchemas = []string{"auth", "storage", "realtime"} + managedSchemas = []string{"auth", "storage", "realtime", "extensions"} ) func Run(ctx context.Context, schema []string, config pgconn.Config, name string, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error {