Skip to content

fix(migrate): name what drift compared in its error - #357

Open
lx3133584 wants to merge 1 commit into
skudra-go:mainfrom
lx3133584:fix/drift-error-names-the-source
Open

lx3133584 wants to merge 1 commit into
skudra-go:mainfrom
lx3133584:fix/drift-error-names-the-source

Conversation

@lx3133584

Copy link
Copy Markdown
Contributor

Fixes #355

Summary

drift already told the user which side it compared — "The database differs from the models. To match, it would need to:" — but the error it returned always read "ant: database differs from the migrations". On an adopting run, with no migrations yet, the last line contradicted it.

The sentinel now carries only the fact, ant: database differs, and drift wraps it with the source it was given: ant: database differs from the models: 3 differences, or from the snapshot when migrations exist. errors.Is(err, migrate.ErrDrift) is unchanged, no caller reads the old text, and the count and its singular form are unchanged. Decision record 177.

Evidence

  • source_test.go (adopting, no versions folder): the error now names the models and no longer says "from the migrations".
  • drift_test.go (a hand-made column change): the error reads ant: database differs from the snapshot: 1 difference.
  • Both assertions failed before with the old ant: database differs from the migrations text; they pass now.
  • go test -count=1 ./... under ANT_TEST_DATABASES=postgres: all packages pass. go build ./..., make fmt, make lint (0 issues) and go test ./tests/docs (index check) pass.

`drift` compares the database with the snapshot, or with the models
when no migration exists yet. Its output named the right side, but the
returned error always read "database differs from the migrations",
contradicting it on an adopting run.

The sentinel now says only "ant: database differs", and the wrap names
the source: "from the models" or "from the snapshot". errors.Is keeps
working, and the count and its singular form are unchanged.

Fixes skudra-go#355
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.

drift says the database differs from the migrations when it compared it with the models

1 participant