mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 19:16:08 +00:00
docs(db): Postgres 14 to 18, the database role, restore limits and the manual rollback
- Database-Postgres: supported versions, the version 18 client and the tool search order, sslrootcert with a client before 16, how to create a role that is not a superuser and move an older compose install to one, a current schema other than public, and the space a restore needs. - Updating: the manual rollback clears the whole schema and loads the copy in one transaction, as TREK's restore does; dropping only the tables left the collation, the trigger functions and the sequences behind. A unit test keeps the printed statement equal to CLEAR_SCHEMA_SQL, and the boot's rollback hint points at that section. - Troubleshooting, Install-Docker-Compose, Environment-Variables, README and server/CLAUDE.md follow.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* The manual rollback in wiki/Updating.md ("Rolling back a Postgres update")
|
||||
* prints the statement TREK's restore clears the schema with
|
||||
* (src/db/engine/postgres/clear-schema.ts), so a rollback by hand clears the
|
||||
* same objects as the tested restore. The page holds a copy; this keeps it the
|
||||
* same as the code.
|
||||
*/
|
||||
import { CLEAR_SCHEMA_SQL } from '../../../../../src/db/engine/postgres/clear-schema';
|
||||
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
const repoRoot = path.resolve(__dirname, '../../../../../..');
|
||||
|
||||
/** The `sql` code blocks of a Markdown text, with the indentation of their fence removed. */
|
||||
function sqlBlocks(markdown: string): string[] {
|
||||
const blocks: string[] = [];
|
||||
const fence = /^( *)```sql\n([\s\S]*?)\n\1```$/gm;
|
||||
for (const match of markdown.replace(/\r\n?/g, '\n').matchAll(fence)) {
|
||||
const indent = match[1].length;
|
||||
blocks.push(
|
||||
match[2]
|
||||
.split('\n')
|
||||
.map((line) => line.slice(Math.min(indent, line.length - line.trimStart().length)))
|
||||
.join('\n'),
|
||||
);
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
describe('clear-schema', () => {
|
||||
it('CLEARSCHEMA-001: the manual rollback on the wiki clears the schema with the statement the restore runs', () => {
|
||||
const page = fs.readFileSync(path.join(repoRoot, 'wiki', 'Updating.md'), 'utf8');
|
||||
const section = page.slice(page.indexOf('### Rolling back a Postgres update'));
|
||||
expect(sqlBlocks(section)).toContain(CLEAR_SCHEMA_SQL.trimEnd());
|
||||
});
|
||||
});
|
||||
@@ -318,7 +318,7 @@ describe('postgresSafetyNet', () => {
|
||||
await expect(hint.restoreHint('20200101000100')).resolves.toMatch(/none of them from this release/);
|
||||
writeFileSync(path.join(dir, 'pre-migrate-20200101000100-20250102T000000Z.pgdump'), 'mine');
|
||||
await expect(hint.restoreHint('20200101000100')).resolves.toMatch(
|
||||
/pre-migrate-20200101000100-20250102T000000Z\.pgdump: stop TREK, empty the database .*pg_restore --no-owner/,
|
||||
/pre-migrate-20200101000100-20250102T000000Z\.pgdump: stop TREK and load it as the wiki page Updating .*pg_restore --no-owner/,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user