namespace EntKube.Web.Data; /// /// Connects a managed database (CNPG or MongoDB) to an app deployment so the /// platform can sync credentials into the app's namespace automatically. /// /// When a binding exists and SyncEnabled is true, any credential sync (including /// after password rotation) will also push a Kubernetes Secret named /// KubernetesSecretName into the AppDeployment's namespace on its cluster. /// The app can then mount the secret as env vars without knowing which database /// provider backs it. /// public class DatabaseBinding { public Guid Id { get; set; } /// /// The CNPG database whose credentials should be synced to the app. /// Mutually exclusive with MongoDatabaseId. /// public Guid? CnpgDatabaseId { get; set; } /// /// The MongoDB database whose credentials should be synced to the app. /// Mutually exclusive with CnpgDatabaseId. /// public Guid? MongoDatabaseId { get; set; } /// /// The deployment that consumes the database credentials. /// The secret is written into this deployment's namespace on its cluster. /// public Guid AppDeploymentId { get; set; } /// /// The Kubernetes Secret name to create in the app's namespace. /// Choose something meaningful to the app (e.g. "billing-db", "app-postgres"). /// public required string KubernetesSecretName { get; set; } /// /// When true, credential syncs (including password rotations) automatically /// propagate to this app's namespace. Disable to pause propagation without /// removing the binding record. /// public bool SyncEnabled { get; set; } = true; /// /// Last time credentials were successfully written to the app's namespace. /// Null means the binding exists but has not been synced yet. /// public DateTime? LastSyncedAt { get; set; } public DateTime CreatedAt { get; set; } = DateTime.UtcNow; // Navigation public CnpgDatabase? CnpgDatabase { get; set; } public MongoDatabase? MongoDatabase { get; set; } public AppDeployment AppDeployment { get; set; } = null!; }