max / makenotwork
1 file changed,
+9 insertions,
-0 deletions
| @@ -358,6 +358,15 @@ pub(crate) async fn reset_scratch(db_url: &str) -> Result<()> { | |||
| 358 | 358 | EXECUTE format('DROP SCHEMA IF EXISTS %I CASCADE', s); | |
| 359 | 359 | END LOOP; | |
| 360 | 360 | EXECUTE 'CREATE SCHEMA public'; | |
| 361 | + | -- Restore the pre-PG15 public-schema default on the throwaway | |
| 362 | + | -- scratch DB. Without this, the freshly-created public is owned by | |
| 363 | + | -- the connecting role (sando) with no grant to anyone else, so a | |
| 364 | + | -- migration's FK/trigger check that Postgres runs as a *restored* | |
| 365 | + | -- prod-owned table's owner (e.g. makenotwork from the backup dump) | |
| 366 | + | -- fails with "permission denied for schema public". Granting to | |
| 367 | + | -- PUBLIC is role-agnostic and safe here — this DB is disposable and | |
| 368 | + | -- exists only to dry-run migrations. | |
| 369 | + | EXECUTE 'GRANT USAGE, CREATE ON SCHEMA public TO PUBLIC'; | |
| 361 | 370 | END $$; | |
| 362 | 371 | "#, | |
| 363 | 372 | ) |