mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-05 10:24:05 +00:00
fix(db): keep Postgres backups and restores inside TREK's schema
pg_dump copied every schema of the database, so on a hosted Postgres such as Supabase a backup carried its auth and storage schemas too, and a restore failed on them. A dump now holds the current schema only, a restore loads only that schema, and a dump without TREK's tables in it is refused before anything is replaced.
This commit is contained in:
@@ -192,13 +192,18 @@ describe('postgresSafetyNet', () => {
|
||||
rmSync(bin, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
/** A stand-in pg_dump that writes its --file, or fails like one that cannot connect. */
|
||||
/**
|
||||
* A stand-in pg_dump that writes its --file, or fails like one that cannot
|
||||
* connect, beside the psql that names the schema the dump is limited to.
|
||||
*/
|
||||
const fakePgDump = (ok: boolean) => {
|
||||
const body = ok
|
||||
? 'for a in "$@"; do case "$a" in --file=*) printf dump > "${a#--file=}";; esac; done'
|
||||
: 'echo "could not connect" >&2; exit 1';
|
||||
writeFileSync(path.join(bin, 'pg_dump'), `#!/bin/sh\n${body}\n`);
|
||||
writeFileSync(path.join(bin, 'psql'), "#!/bin/sh\nprintf 'public\\tpublic\\n'\n");
|
||||
chmodSync(path.join(bin, 'pg_dump'), 0o755);
|
||||
chmodSync(path.join(bin, 'psql'), 0o755);
|
||||
};
|
||||
const envWith =
|
||||
(preMigrateSnapshot: boolean | undefined, isTest: boolean, keep = 3) =>
|
||||
|
||||
Reference in New Issue
Block a user