Skip to content

Commit

Permalink
chore: db user prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Alxandr committed Oct 8, 2024
1 parent dd4e356 commit 2cdff68
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ internal sealed class BootstrapDatabasePipeline
[JsonPropertyName("databaseName")]
public required string DatabaseName { get; init; }

[JsonPropertyName("userPrefix")]
public required string UserPrefix { get; init; }

[JsonPropertyName("schemas")]
public required IReadOnlyDictionary<string, SchemaBootstrapModel> Schemas { get; init; }

Expand Down Expand Up @@ -72,8 +75,8 @@ await context.RunTask(
(_, ct) => serverConn.OpenAsync(ct),
cancellationToken);

var migratorUser = await context.RunTask(new CreateDatabaseRoleTask(secretClient, serverConn, $"{DatabaseName}_migrator", Resources.User), cancellationToken);
var appUser = await context.RunTask(new CreateDatabaseRoleTask(secretClient, serverConn, $"{DatabaseName}_app", Resources.User), cancellationToken);
var migratorUser = await context.RunTask(new CreateDatabaseRoleTask(secretClient, serverConn, $"{UserPrefix}_migrator", Resources.User), cancellationToken);
var appUser = await context.RunTask(new CreateDatabaseRoleTask(secretClient, serverConn, $"{UserPrefix}_app", Resources.User), cancellationToken);
await context.RunTask(new CreateDatabaseTask(serverConn, DatabaseName), cancellationToken);
await context.RunTask(new GrantDatabasePrivilegesTask(serverConn, DatabaseName, migratorUser.RoleName, "CREATE, CONNECT"), cancellationToken);
await context.RunTask(new GrantDatabasePrivilegesTask(serverConn, DatabaseName, appUser.RoleName, "CONNECT"), cancellationToken);
Expand Down

0 comments on commit 2cdff68

Please sign in to comment.