Some checks failed
CI / Lint, typecheck, test (pull_request) Successful in 6m48s
CI / Build container images (pull_request) Successful in 1m46s
CI / Auth e2e pack (pull_request) Successful in 8m22s
CI / Import/export fidelity gate (pull_request) Successful in 1m8s
CD / Deploy to Test (push) Blocked by required conditions
CD / Smoke tests against Test (push) Blocked by required conditions
CD / Promote to Int (push) Blocked by required conditions
CI / Auth e2e pack (push) Blocked by required conditions
CI / Import/export fidelity gate (push) Blocked by required conditions
CI / Build container images (push) Blocked by required conditions
CD / Build and push images (push) Has been cancelled
CI / Lint, typecheck, test (push) Has been cancelled
Since #224 read_events is partitioned; the dump carries per-partition primary keys as own entries, and pg_restore --clean emitted DROP CONSTRAINT against inherited constraints, which PostgreSQL refuses. The restore then reported FAILED although the content was restored. Dropping and recreating the public schema first makes every --clean drop a no-op and the restore faithful: objects created after the backup no longer survive. Verified in the isolated environment of #220 (set 20260731-132200, exit 0, readyz green). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AUtYMxwTCMHG9mVHnwbFg8
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { pgEnvFromUrl, pgRestoreArgs, schemaResetArgs, schemaResetSql } from './pg.js';
|
|
|
|
describe('pgEnvFromUrl', () => {
|
|
it('maps the URL onto libpq env vars, never argv', () => {
|
|
expect(pgEnvFromUrl('postgresql://user:p%40ss@db:5433/dorfteich')).toEqual({
|
|
PGHOST: 'db',
|
|
PGPORT: '5433',
|
|
PGUSER: 'user',
|
|
PGPASSWORD: 'p@ss',
|
|
PGDATABASE: 'dorfteich',
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('restore command plan (issue #288)', () => {
|
|
it('resets the schema first — --clean alone cannot drop inherited partition PKs', () => {
|
|
expect(schemaResetSql).toBe('DROP SCHEMA IF EXISTS public CASCADE; CREATE SCHEMA public;');
|
|
expect(schemaResetArgs('dorfteich')).toEqual([
|
|
'--dbname',
|
|
'dorfteich',
|
|
'--set',
|
|
'ON_ERROR_STOP=1',
|
|
'--command',
|
|
schemaResetSql,
|
|
]);
|
|
});
|
|
|
|
it('keeps --clean --if-exists as no-op belt and braces on the empty schema', () => {
|
|
expect(pgRestoreArgs('dorfteich', '/backups/x.dump')).toEqual([
|
|
'--clean',
|
|
'--if-exists',
|
|
'--no-owner',
|
|
'--dbname',
|
|
'dorfteich',
|
|
'/backups/x.dump',
|
|
]);
|
|
});
|
|
});
|