Propel.FeatureFlags.PostgreSql
2.2.1
dotnet add package Propel.FeatureFlags.PostgreSql --version 2.2.1
NuGet\Install-Package Propel.FeatureFlags.PostgreSql -Version 2.2.1
<PackageReference Include="Propel.FeatureFlags.PostgreSql" Version="2.2.1" />
<PackageVersion Include="Propel.FeatureFlags.PostgreSql" Version="2.2.1" />
<PackageReference Include="Propel.FeatureFlags.PostgreSql" />
paket add Propel.FeatureFlags.PostgreSql --version 2.2.1
#r "nuget: Propel.FeatureFlags.PostgreSql, 2.2.1"
#:package Propel.FeatureFlags.PostgreSql@2.2.1
#addin nuget:?package=Propel.FeatureFlags.PostgreSql&version=2.2.1
#tool nuget:?package=Propel.FeatureFlags.PostgreSql&version=2.2.1
Propel.FeatureFlags.PostgreSql
PostgreSQL repository implementation for Propel.FeatureFlags, providing persistent storage for feature flag configurations and evaluations.
Features
- PostgreSQL Storage - Feature flag storage using PostgreSQL
- Connection Pooling - Connection management with configurable pool settings
- Auto-Initialization - Automatic database and table creation on startup
- Resilience Configuration - Built-in timeout and retry settings for production workloads
- Schema Management - Handles database schema creation and migrations automatically
Installation
dotnet add package Propel.FeatureFlags.PostgreSql
Quick Start
Basic Configuration
using Propel.FeatureFlags.PostgreSql.Extensions;
var builder = WebApplication.CreateBuilder(args);
// Add PostgreSQL feature flag repository
builder.Services
.ConfigureFeatureFlags(config =>
{
config.RegisterFlagsWithContainer = true;
config.EnableFlagFactory = true;
})
.AddPostgreSqlFeatureFlags(builder.Configuration.GetConnectionString("DefaultConnection")!);
var app = builder.Build();
// Initialize database (development only)
if (app.Environment.IsDevelopment())
{
await app.InitializeFeatureFlagsDatabase();
}
// Auto-deploy flags to database
await app.AutoDeployFlags();
app.Run();
Console Application
using Propel.FeatureFlags.PostgreSql.Extensions;
var builder = Host.CreateApplicationBuilder(args);
builder.Services
.ConfigureFeatureFlags(config =>
{
config.RegisterFlagsWithContainer = true;
config.EnableFlagFactory = true;
})
.AddPostgreSqlFeatureFlags(builder.Configuration.GetConnectionString("DefaultConnection")!);
var app = builder.Build();
// Initialize database in development
if (app.Services.GetRequiredService<IHostEnvironment>().IsDevelopment())
{
await app.InitializeFeatureFlagsDatabase();
}
await app.AutoDeployFlags();
await app.RunAsync();
Configuration
Connection String The extension automatically configures the PostgreSQL connection with optimized settings:
{
"ConnectionStrings": {
"DefaultConnection": "Host=localhost,5432;Database=feature_flags;Search Path=example;Username=postgres-user;Password=postgres-password"
}
}
Automatic Connection Optimization
The AddPostgreSqlFeatureFlags() method automatically applies the following settings:
| Setting | Value | Description |
|---|---|---|
| CommandTimeout | 30 seconds | Maximum time for command execution |
| Timeout | 15 seconds | Connection timeout |
| MaxPoolSize | 100 | Maximum connections in pool |
| MinPoolSize | 5 | Minimum connections in pool |
| Pooling | true | Enable connection pooling |
| ConnectionIdleLifetime | 300 seconds | Idle connection lifetime |
| ConnectionPruningInterval | 10 seconds | Pool cleanup interval |
| ApplicationName | PropelFeatureFlags | Identifier in PostgreSQL logs |
Extension Methods
AddPostgreSqlFeatureFlags(string connectionString) registers PostgreSQL as the feature flag repository with optimized connection settings.
builder.Services
.ConfigureFeatureFlags(config => { ... })
.AddPostgreSqlFeatureFlags(connectionString);
InitializeFeatureFlagsDatabase() creates the database schema if it doesn't exist. Recommended for development environments only.
if (app.Environment.IsDevelopment())
{
await app.InitializeFeatureFlagsDatabase();
}
Important Notes:
- In production, this method will throw an exception and stop the application if initialization fails
- In development/staging, the application continues running to allow troubleshooting
- Only call this method during application startup, not on every request
Database Schema
The extension automatically creates the following database objects:
- Tables - Feature flags, variations, targeting rules, rollout configurations
- Indexes - Optimized for common query patterns
- Constraints - Ensures data integrity
Schema creation happens automatically when calling InitializeFeatureFlagsDatabase().
Production Deployment
For production environments, it's recommended to deploy the database schema from CI/CD pipelines instead of using InitializeFeatureFlagsDatabase().
You can use the Propel CLI utility to automate schema deployment as part of your deployment pipeline.
This approach provides better control over database changes, enables schema versioning, and follows infrastructure-as-code best practices.
Example CI/CD pipeline command
propel-cli migrate --connection-string "Host=prod_server;Database=feature_flags;..."
Usage Example
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services
.ConfigureFeatureFlags(config =>
{
config.RegisterFlagsWithContainer = true;
config.EnableFlagFactory = true;
})
.AddPostgreSqlFeatureFlags(Configuration.GetConnectionString("DefaultConnection")!);
}
public async Task Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
// Create database schema
await app.ApplicationServices
.GetRequiredService<IHost>()
.InitializeFeatureFlagsDatabase();
}
// Deploy flags to database
await app.ApplicationServices
.GetRequiredService<IHost>()
.AutoDeployFlags();
}
}
Related Packages
- Propel.FeatureFlags - Core feature flag library
- Propel.FeatureFlags.DependencyInjection.Extensions - Container extensions
- Propel.FeatureFlags.Redis - Redis caching provider
- Propel.FeatureFlags.AspNetCore - ASP.NET Core middleware
- Propel.FeatureFlags.Attributes - Attribute-based feature flagging
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net9.0
- Npgsql (>= 9.0.3)
- Propel.FeatureFlags (>= 2.2.1)
- Propel.FeatureFlags.AspNetCore (>= 2.2.1)
- Propel.FeatureFlags.Attributes (>= 2.2.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.2.1 | 167 | 10/20/2025 |
| 2.2.1-beta.1.2 | 116 | 10/19/2025 |
| 2.1.1-beta.1.2 | 43 | 10/18/2025 |
| 2.1.0-beta.1.2 | 120 | 10/16/2025 |
| 2.0.0-beta.1.2 | 126 | 10/14/2025 |
| 1.0.1-beta.1 | 124 | 10/7/2025 |
| 1.0.0-beta.1 | 123 | 10/7/2025 |