Sitelet https://github.com/cybertec-postgresql/pgwatch/pull/1111
Skip to content

[!] add schema migration support for PostgreSQL sinks, closes #1110 - #1111

Merged
pashagolub merged 3 commits into
masterfrom
1110-apply-postgres-sink-schema-migrations
Jan 5, 2026
Merged

pashagolub merged 3 commits into
masterfrom
1110-apply-postgres-sink-schema-migrations

Conversation

@pashagolub

Copy link
Copy Markdown
Collaborator
  • Add admin.migration table and migration infrastructure to sink
  • Implement Migrate() and NeedsMigration() for PostgresWriter and MultiWriter
  • Add migration checks during sink initialization with error messages
  • Extend config init/upgrade commands to support sink migrations
  • NewWriterFromPostgresConn now returns nil writer on errors
  • Add comprehensive test coverage for migration happy/unhappy paths
  • Update docs to document sink database migration support

Migration pattern follows existing metrics database approach, ensuring both config and sink databases can be upgraded independently using the same pgwatch config upgrade command.

- Add `admin.migration` table and migration infrastructure to sink
- Implement `Migrate()` and `NeedsMigration()` for `PostgresWriter` and
`MultiWriter`
- Add migration checks during sink initialization with error messages
- Extend `config init/upgrade` commands to support sink migrations
- `NewWriterFromPostgresConn` now returns nil writer on errors
- Add comprehensive test coverage for migration happy/unhappy paths
- Update docs to document sink database migration support

Migration pattern follows existing metrics database approach, ensuring
both config and sink databases can be upgraded independently using the
same `pgwatch config upgrade` command.
@coveralls

coveralls commented Jan 4, 2026 •

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 20717611432

Details

  • 99 of 124 (79.84%) changed or added relevant lines in 5 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.7%) to 74.573%

Changes Missing Coverage Covered Lines Changed/Added Lines %
internal/sinks/postgres.go 49 52 94.23%
internal/cmdopts/cmdconfig.go 13 35 37.14%
Totals Coverage Status
Change from base Build 20659178727: 0.7%
Covered Lines: 3971
Relevant Lines: 5325

馃挍 - Coveralls

@pashagolub pashagolub self-assigned this Jan 4, 2026
@pashagolub pashagolub added enhancement New feature or request sinks Where and how to store monitored data labels Jan 4, 2026
@pashagolub
pashagolub force-pushed the 1110-apply-postgres-sink-schema-migrations branch from 8d3c63f to b8e65f8 Compare January 4, 2026 13:54
@pashagolub
pashagolub merged commit 2a147ad into master Jan 5, 2026
9 checks passed
@pashagolub
pashagolub deleted the 1110-apply-postgres-sink-schema-migrations branch January 5, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request sinks Where and how to store monitored data

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants