Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions cypress/e2e/settings/prowlarr-responsive.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe('Prowlarr settings on a short mobile screen', () => {
},
});
} else if (pathname === '/api/v1/settings/prowlarr') {
request.alias = 'prowlarrSettings';
request.reply({
hostname: 'prowlarr.test',
port: 9696,
Expand Down Expand Up @@ -113,6 +114,8 @@ describe('Prowlarr settings on a short mobile screen', () => {

it('keeps save reachable after scrolling the long indexer report', () => {
cy.visit('/settings/services');
cy.wait('@prowlarrSettings').its('response.statusCode').should('eq', 200);
cy.get('#prowlarr').should('be.visible');
cy.contains('#prowlarr h3', 'Prowlarr indexers').scrollIntoView();
cy.get('#prowlarr')
.contains('button', 'Test connection and inspect coverage')
Expand Down
61 changes: 61 additions & 0 deletions docs/maintainers/postgres-startup-issue-164.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# PostgreSQL Startup Recovery — Issue #164

## Recovery identity

- Base: `a9dd1b5a64cd9ccabe59da198b0524a7886bb708` (`origin/main`).
- Issue fix commit: `0980bc5d1db052f566cd97b46b98a89149a34952`.
- Supporting packaging-fixture test commit: `e87fef1e4374eadf0b3e15667eb57f44ccc5a6ff`.
- Upstream issue: https://github.com/snapetech/seerrng/issues/164.
- Pre-audit recovery archive: `/tmp/seerrng-issue164-preaudit-20261006.tar`.

## Root cause and changes

Three `@UpdateDateColumn` decorators passed SQLite's `datetime` type directly
to TypeORM. PostgreSQL rejects that type while building entity metadata, before
startup reaches the migration runner. The affected columns are
`ReaderDeliveryGrouping.updatedAt`, `GameLibraryAccount.updatedAt`, and
`GameLibraryEntry.updatedAt`.

The fix resolves those types for the active database and adds a reversible
PostgreSQL migration to normalize nine private-library date columns, preserving
their wall-clock values under the session timezone. The issue commit includes a
metadata regression test, migration test, and release-note fragment.

## Verification

- Before rebasing, full Linux `pnpm test:ci`: 487 files passed, 1 skipped; 3,375 tests passed,
4 skipped; 0 failures. The four skips were PostgreSQL-gated tests.
- Before rebasing, focused PostgreSQL 18 Node run: 5 passed, 0 failed, 0 skipped. This included
all four database-gated migration tests and the issue migration query test.
- Focused Linux Vitest metadata regression: 1 passed.
- Disposable PostgreSQL 18 migration round-trip (before rebase, same issue
commit contents): all nine columns converted up and down, preserving values
under an `America/Edmonton` session timezone.
- Before rebasing, Linux `pnpm build`: passed. Translation extraction, 569-file current-batch
contract, shared-style checks, 68 button/geometry tests, server compilation,
Next.js compilation, and all 113 static pages completed.
- Release-note preview rendered the PostgreSQL startup fix note.
- Before rebasing, `pnpm validate:development` on Linux ARM64 passed formatting, lint, types,
Vitest (100 files; 453 tests), native TypeScript (2,912 passed, 4 skipped),
and native JavaScript (485 tests). It failed one tooling test because its
archive fixture assumed x64. The corrected fixture now passes 7/7 locally;
the full gate was not rerun after that test-only correction.
- A full `pnpm test:node` attempt was stopped after 9m15s while compiling an
unrelated Jellyfin suite. No failure was reported; that full lane is not
counted as passed. Focused relevant Node tests passed separately.
- The reviewed combined validation engine was not run. Historical
`pnpm validate:development` attempts on the prior base had platform/tooling
failures. The complete gate has not been rerun on the rebased candidate.
- Initial PR Cypress CI ran 43 specs (185 tests): 152 passed, 1 failed, and
32 were pending. The failure was the Prowlarr settings heading being absent
when the test queried it. The component renders after its settings response;
the Cypress test now aliases and waits for that mocked request, then checks
the section is visible before continuing its existing interaction checks.
The updated Cypress test has not been rerun; the next push will trigger CI.
- No live database, account, or provider was used.

## Release

Before publication, the latest published tag was `v3.52.1`. The repository's
`Create tag` workflow determines the next version from unreleased conventional
commits on `main`.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
category: fixed
audience: users, operators
area: database
action: none
breaking: false
---

PostgreSQL startup now accepts the reader delivery and private game library date columns, so these features no longer prevent the application from starting.
84 changes: 61 additions & 23 deletions scripts/build-release-assets.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ const writeNodeArchitectureShim = (fixture) =>
{ mode: 0o755 }
);

const writeUnameShim = (fixture, system, machine) =>
fs.writeFile(
path.join(fixture.executableDirectory, 'uname'),
`#!/bin/sh\nif [ "$1" = "-s" ]; then printf '%s\\n' '${system}'; else printf '%s\\n' '${machine}'; fi\n`,
{ mode: 0o755 }
);

const run = (fixture, arguments_, environment = {}) =>
new Promise((resolve) => {
const child = spawn(fixture.script, arguments_, {
Expand All @@ -104,6 +111,35 @@ const run = (fixture, arguments_, environment = {}) =>
child.on('close', (code) => resolve({ code, output }));
});

const runForPlatformAndNodeArchitecture = async (
fixture,
arguments_,
system,
machine,
architecture,
environment = {}
) => {
await Promise.all([
writeNodeArchitectureShim(fixture),
writeUnameShim(fixture, system, machine),
]);
return run(fixture, arguments_, {
...environment,
TEST_NODE_ARCH: architecture,
TEST_NODE_BINARY: process.execPath,
});
};

const runAsLinuxX64 = (fixture, arguments_, environment = {}) =>
runForPlatformAndNodeArchitecture(
fixture,
arguments_,
'Linux',
'x86_64',
'x64',
environment
);

const extractArchive = (archive, destination) =>
new Promise((resolve, reject) => {
const child = spawn('tar', ['-xzf', archive, '-C', destination]);
Expand Down Expand Up @@ -133,7 +169,7 @@ describe('release asset construction', () => {
await fs.writeFile(sentinel, 'unchanged');
await fs.symlink(sentinel, archive);

const result = await run(fixture, ['v1.2.3', distribution]);
const result = await runAsLinuxX64(fixture, ['v1.2.3', distribution]);

assert.equal(result.code, 0, result.output);
assert.match(
Expand Down Expand Up @@ -222,7 +258,7 @@ describe('release asset construction', () => {
path.join(fixture.root, 'public', 'escape')
);

const result = await run(fixture, ['v1.2.3', distribution]);
const result = await runAsLinuxX64(fixture, ['v1.2.3', distribution]);

assert.notEqual(result.code, 0);
assert.match(result.output, /Refusing absolute archive symlink/);
Expand All @@ -238,7 +274,7 @@ describe('release asset construction', () => {
const asset = 'seerrng-v1.2.3-linux-x64';
const archive = path.join(distribution, `${asset}.tar.gz`);
await fs.mkdir(distribution);
const result = await run(fixture, ['v1.2.3', distribution]);
const result = await runAsLinuxX64(fixture, ['v1.2.3', distribution]);

assert.equal(result.code, 0, result.output);
const extracted = path.join(fixture.root, 'extracted');
Expand All @@ -255,20 +291,20 @@ describe('release asset construction', () => {
const archive = path.join(distribution, 'seerrng-v1.2.3-windows-x64.zip');
const archiverLog = path.join(fixture.root, 'archiver.log');
await fs.mkdir(distribution);
await fs.writeFile(
path.join(fixture.executableDirectory, 'uname'),
'#!/bin/sh\nif [ "$1" = "-s" ]; then echo MINGW64_NT; else echo x86_64; fi\n',
{ mode: 0o755 }
);
await fs.writeFile(
path.join(fixture.executableDirectory, '7z'),
'#!/bin/sh\nprintf \'%s\\n\' "$*" >"$ARCHIVER_LOG"\nprevious_argument=\'\'\nfor argument in "$@"; do\n archive_path="$previous_argument"\n stage_path="$argument"\n previous_argument="$argument"\ndone\nzip -qr "$archive_path" "$stage_path"\n',
{ mode: 0o755 }
);

const result = await run(fixture, ['v1.2.3', distribution], {
ARCHIVER_LOG: archiverLog,
});
const result = await runForPlatformAndNodeArchitecture(
fixture,
['v1.2.3', distribution],
'MINGW64_NT',
'x86_64',
'x64',
{ ARCHIVER_LOG: archiverLog }
);

assert.equal(result.code, 0, result.output);
assert.match(
Expand Down Expand Up @@ -306,12 +342,13 @@ describe('release asset construction', () => {
it('rejects Linux ARMv7 without a supported Node.js 24 runtime', async () => {
const fixture = await createFixture();
const distribution = path.join(fixture.root, 'dist-release');
await writeNodeArchitectureShim(fixture);

const result = await run(fixture, ['v1.2.3', distribution], {
TEST_NODE_ARCH: 'armv7l',
TEST_NODE_BINARY: process.execPath,
});
const result = await runForPlatformAndNodeArchitecture(
fixture,
['v1.2.3', distribution],
'Linux',
'armv7l',
'armv7l'
);

assert.notEqual(result.code, 0);
assert.match(
Expand All @@ -327,12 +364,13 @@ describe('release asset construction', () => {
it('rejects an architecture outside the published archive matrix', async () => {
const fixture = await createFixture();
const distribution = path.join(fixture.root, 'dist-release');
await writeNodeArchitectureShim(fixture);

const result = await run(fixture, ['v1.2.3', distribution], {
TEST_NODE_ARCH: 'riscv64',
TEST_NODE_BINARY: process.execPath,
});
const result = await runForPlatformAndNodeArchitecture(
fixture,
['v1.2.3', distribution],
'Linux',
'riscv64',
'riscv64'
);

assert.notEqual(result.code, 0);
assert.match(
Expand Down
6 changes: 4 additions & 2 deletions server/entity/GameLibraryAccount.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DbAwareColumn } from '@server/utils/DbColumnHelper';
import { DbAwareColumn, resolveDbType } from '@server/utils/DbColumnHelper';
import {
Column,
Entity,
Expand Down Expand Up @@ -43,6 +43,8 @@ export default class GameLibraryAccount {
@DbAwareColumn({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' })
public linkedAt: Date;

@UpdateDateColumn({ type: 'datetime' })
@UpdateDateColumn({
type: resolveDbType('datetime'),
})
public updatedAt: Date;
}
6 changes: 4 additions & 2 deletions server/entity/GameLibraryEntry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DbAwareColumn } from '@server/utils/DbColumnHelper';
import { DbAwareColumn, resolveDbType } from '@server/utils/DbColumnHelper';
import {
Column,
Entity,
Expand Down Expand Up @@ -98,6 +98,8 @@ export default class GameLibraryEntry {
@DbAwareColumn({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' })
public createdAt: Date;

@UpdateDateColumn({ type: 'datetime' })
@UpdateDateColumn({
type: resolveDbType('datetime'),
})
public updatedAt: Date;
}
6 changes: 4 additions & 2 deletions server/entity/ReaderDeliveryGrouping.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DbAwareColumn } from '@server/utils/DbColumnHelper';
import { DbAwareColumn, resolveDbType } from '@server/utils/DbColumnHelper';
import {
Column,
Entity,
Expand Down Expand Up @@ -68,6 +68,8 @@ export default class ReaderDeliveryGrouping {
@DbAwareColumn({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' })
public createdAt: Date;

@UpdateDateColumn({ type: 'datetime' })
@UpdateDateColumn({
type: resolveDbType('datetime'),
})
public updatedAt: Date;
}
47 changes: 47 additions & 0 deletions server/entity/postgresDateMetadata.vitest.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { afterEach, describe, expect, it, vi } from 'vitest';

describe('PostgreSQL entity date metadata', () => {
afterEach(() => {
vi.doUnmock('@server/utils/dbType');
vi.resetModules();
});

it('builds metadata for date columns on entities added in SeerrNG 3.52', async () => {
vi.resetModules();
vi.doMock('@server/utils/dbType', () => ({ isPgsql: true }));

const { DataSource, getMetadataArgsStorage } = await import('typeorm');
const [
{ default: ReaderDeliveryGrouping },
{ default: GameLibraryAccount },
{ default: GameLibraryEntry },
] = await Promise.all([
import('./ReaderDeliveryGrouping'),
import('./GameLibraryAccount'),
import('./GameLibraryEntry'),
]);

const source = new DataSource({
type: 'postgres',
database: 'metadata-test',
entities: [ReaderDeliveryGrouping],
});
await (
source as unknown as { buildMetadatas: () => Promise<void> }
).buildMetadatas();

const metadata = getMetadataArgsStorage();
for (const target of [
ReaderDeliveryGrouping,
GameLibraryAccount,
GameLibraryEntry,
]) {
const updatedAt = metadata.columns.find(
(column) =>
column.target === target && column.propertyName === 'updatedAt'
);

expect(updatedAt?.options.type).toBe('timestamp with time zone');
}
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import type { QueryRunner } from 'typeorm';
import { NormalizePrivateLibraryTimestamps1791040000000 } from './1791040000000-NormalizePrivateLibraryTimestamps';

const timestampColumns = [
['game_library_entry', 'lastSyncedAt'],
['game_library_entry', 'createdAt'],
['game_library_entry', 'updatedAt'],
['game_library_account', 'lastSyncedAt'],
['game_library_account', 'linkedAt'],
['game_library_account', 'updatedAt'],
['reader_delivery_grouping', 'lastSyncedAt'],
['reader_delivery_grouping', 'createdAt'],
['reader_delivery_grouping', 'updatedAt'],
] as const;

test('normalizes private-library PostgreSQL timestamp types using the configured timezone', async () => {
const statements: string[] = [];
const queryRunner = {
query: async (statement: string) => {
statements.push(statement.replace(/\s+/g, ' ').trim());
},
} as unknown as QueryRunner;
const migration = new NormalizePrivateLibraryTimestamps1791040000000();

await migration.up(queryRunner);
assert.equal(statements.length, timestampColumns.length);
for (const [table, column] of timestampColumns) {
assert.ok(
statements.includes(
`ALTER TABLE "${table}" ALTER COLUMN "${column}" TYPE TIMESTAMP WITH TIME ZONE USING "${column}" AT TIME ZONE current_setting('TimeZone')`
)
);
}

statements.length = 0;
await migration.down(queryRunner);
assert.equal(statements.length, timestampColumns.length);
for (const [table, column] of [...timestampColumns].reverse()) {
assert.ok(
statements.includes(
`ALTER TABLE "${table}" ALTER COLUMN "${column}" TYPE TIMESTAMP WITHOUT TIME ZONE USING "${column}" AT TIME ZONE current_setting('TimeZone')`
)
);
}
});
Loading
Loading