@getstrata/core 2.0.6 → 2.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # @getstrata/core changelog
2
2
 
3
+ ## 2.0.7
4
+
5
+ - Fix concurrent Postgres role provisioning across databases
6
+
3
7
  ## 2.0.6
4
8
 
5
9
  - Dispatch registered Bun route preflights through CORS
@@ -175,6 +175,9 @@ function postgresAppRoleCreateSql(options = {}) {
175
175
  const password = quoteSqlLiteral(options.password ?? POSTGRES_APP_ROLE_PASSWORD);
176
176
  return `DO $$
177
177
  BEGIN
178
+ -- pg_authid is shared across databases. Database-local advisory locks cannot
179
+ -- serialize a cluster-global role. This lock permits readers and lasts until commit.
180
+ LOCK TABLE pg_catalog.pg_authid IN SHARE ROW EXCLUSIVE MODE;
178
181
  IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = '${role}') THEN
179
182
  CREATE ROLE ${role} LOGIN PASSWORD ${password}
180
183
  NOSUPERUSER NOCREATEDB NOCREATEROLE NOINHERIT NOBYPASSRLS;
@@ -216,8 +219,7 @@ async function grantPostgresAppRolePrivileges(sql, options) {
216
219
  await sql.unsafe(`ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT EXECUTE ON FUNCTIONS TO ${role}`);
217
220
  }
218
221
  async function ensurePostgresAppRole(sql, options) {
219
- await sql.unsafe(postgresAppRoleCreateSql(options));
220
- await grantPostgresAppRolePrivileges(sql, options);
222
+ await sql.unsafe(postgresAppRoleSql(options));
221
223
  }
222
224
  async function ensurePostgresDatabaseAndAppRole(options) {
223
225
  const name = postgresDatabaseNameFromUrl(options.runtimeUrl);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getstrata/core",
3
- "version": "2.0.6",
3
+ "version": "2.0.7",
4
4
  "description": "Strata Bun framework public API",
5
5
  "type": "module",
6
6
  "license": "MIT",