mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 02:56:10 +00:00
633e9bcdc1
- 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.
39 lines
1.5 KiB
TypeScript
39 lines
1.5 KiB
TypeScript
/**
|
|
* 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());
|
|
});
|
|
});
|