~20 GB of the NVMe, read by key only; the catalog was at its cap and history paused. Moved on homelab by hand (3 min, writers stopped; the cap raised to 100); the migration does the same on a new deploy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
33 lines
1.3 KiB
TypeScript
33 lines
1.3 KiB
TypeScript
import { BaseSchema } from '@adonisjs/lucid/schema'
|
|
import env from '#start/env'
|
|
|
|
/**
|
|
* par2_files, fragments and probe_cache, with their indexes, in CHUNK_TABLESPACE (the HDD): ~20 GB of the NVMe at
|
|
* 42M releases, read by key only (the merger, the fragment merger, the prober). The catalog was at its
|
|
* CATALOG_MAX_NVME_GB cap and history paused (LOG.md 2026-10-14 (55)). Homelab was moved by hand first (3 min,
|
|
* with the writers stopped); a no-op where they're there already.
|
|
*/
|
|
const TABLES = ['par2_files', 'fragments', 'probe_cache']
|
|
|
|
export default class extends BaseSchema {
|
|
async up() {
|
|
const tablespace = env.get('CHUNK_TABLESPACE')
|
|
if (!tablespace) return
|
|
this.defer(async (db) => {
|
|
for (const table of TABLES) {
|
|
const { rows } = await db.rawQuery(
|
|
`SELECT c.relname, c.relkind FROM pg_class c LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace
|
|
WHERE (c.relname = ? OR c.oid IN (SELECT indexrelid FROM pg_index WHERE indrelid = ?::regclass))
|
|
AND coalesce(t.spcname, 'pg_default') <> ?`,
|
|
[table, table, tablespace]
|
|
)
|
|
for (const { relname, relkind } of rows) {
|
|
await db.rawQuery(`ALTER ${relkind === 'i' ? 'INDEX' : 'TABLE'} ${relname} SET TABLESPACE ${tablespace}`)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
|
|
async down() {}
|
|
}
|