Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions internal/db/pull/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ import (
)

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"}
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)
)

func Run(ctx context.Context, schema []string, config pgconn.Config, name string, fsys afero.Fs, options ...func(*pgx.ConnConfig)) error {
Expand Down Expand Up @@ -61,8 +60,8 @@ func run(ctx context.Context, schema []string, path string, conn *pgx.Conn, fsys
if err = dumpRemoteSchema(ctx, path, config, fsys); err != nil {
return err
}
// Pull changes in managed schemas automatically
if err = diffRemoteSchema(ctx, managedSchemas, path, config, fsys); errors.Is(err, errInSync) {
// Run a second pass to pull in changes from default privileges and managed schemas
if err = diffRemoteSchema(ctx, nil, path, config, fsys); errors.Is(err, errInSync) {
err = nil
}
return err
Expand Down
3 changes: 0 additions & 3 deletions pkg/migration/scripts/dump_schema.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,3 @@ pg_dump \
| sed -E 's/^ALTER TABLE "cron"/-- &/' \
| sed -E 's/^SET transaction_timeout = 0;/-- &/' \
| sed -E "${EXTRA_SED:-}"

# Reset session config generated by pg_dump
echo "RESET ALL;"
Loading