Skip to content

Conversation

@diiviikk5
Copy link

Fixes #1114

The upgrade command now accepts --sink alone when sources/metrics use yaml files.

Removed the validation that required both --sources and --metrics to be postgres URLs. Each config type is now upgraded independently if available.

@diiviikk5
Copy link
Author

so afaik the config init command handles sources/metrics/sinks independently, but upgrade didn't ?. Is there a reason upgrade originally required both? Just curious

@pashagolub pashagolub added bug Something isn't working sinks Where and how to store monitored data labels Jan 22, 2026
var upgraded bool

// Upgrade metrics/sources configuration if both are postgres
if hasMetricsPg && hasSourcesPg {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's wrong. We must not depend on both options be the same of a kind. upgrade command must work with every option independently

Copy link
Author

@diiviikk5 diiviikk5 Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So basically , - if metrics is postgres, upgrade it; if sources is postgres, upgrade it separately. ? Ill look into it

@coveralls
Copy link

coveralls commented Jan 22, 2026

Pull Request Test Coverage Report for Build 21245920934

Details

  • 21 of 34 (61.76%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.07%) to 75.369%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/cmdopts/cmdconfig.go 21 34 61.76%
Totals Coverage Status
Change from base Build 21245085454: 0.07%
Covered Lines: 4033
Relevant Lines: 5351

💛 - Coveralls

@pashagolub pashagolub force-pushed the fix-sink-only-upgrade-1114 branch from 816494c to 25531be Compare January 22, 2026 10:48
@diiviikk5 diiviikk5 force-pushed the fix-sink-only-upgrade-1114 branch from 25531be to 51a709a Compare January 22, 2026 11:00
@diiviikk5
Copy link
Author

made them independent , @pashagolub , any other changes or feedback?

Comment on lines 92 to 94
hasMetricsPg := opts.IsPgConnStr(opts.Metrics.Metrics)
hasSourcesPg := opts.IsPgConnStr(opts.Sources.Sources)
hasSinks := len(opts.Sinks.Sinks) > 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why only Postgres is here? What if later we want to upgrade YAML files from old format to a new one?

We should rely on checking if smth supports metrics.Migrator interface.

Comment on lines -88 to -90
if err = opts.ValidateConfig(); err != nil {
return
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a correct idea! Validating is needed for a normal work but for a command we shall check in-place.

@pashagolub
Copy link
Collaborator

pashagolub commented Jan 22, 2026

also, please, do not overwrite my rebases ;-)

diiviikk5(Divik Arora) force-pushed the fix-sink-only-upgrade-1114 branch from 25531be to 51a709a

Please, make sure your branch is rebased against master

When using yaml for sources/metrics, you can now run:
  pgwatch --sink=postgres://... config upgrade

Previously this would fail asking for --sources and --metrics.
@diiviikk5 diiviikk5 force-pushed the fix-sink-only-upgrade-1114 branch from 51a709a to 5d1c0f9 Compare January 24, 2026 09:48
@diiviikk5
Copy link
Author

diiviikk5 commented Jan 24, 2026

sorry couldnt update earlier @pashagolub i was ill ,but thanks for reviewing the code properly it helps me learn , i did the rebase against the latest master , Metrics, sources, and sinks are upgraded independently

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working sinks Where and how to store monitored data

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't upgrade sink schema if using yaml source and metric configs

4 participants