ArchiveBox/archivebox/api
Claude 7167c5dd8a
Add native PostgreSQL support alongside SQLite
Add DATABASE_ENGINE=postgres (plus DATABASE_HOST/PORT/USER/PASSWORD/NAME)
config and centralize all sqlite-vs-postgres branching in
archivebox.misc.db:

- get_database_settings() builds DATABASES for either backend; the sqlite
  path is unchanged (custom lock-retry backend, same PRAGMAs).
- database_exists()/ensure_database_ready() replace index.sqlite3 file
  checks; init auto-creates the postgres database when missing.
- approximate_row_counts() serves admin index counts from sqlite_stat1 or
  pg_class.reltuples; missing-table detection covers both vendors.
- rebuild_models_from_migration_state() lets historical sqlite-only raw
  SQL migrations resync postgres schema from Django migration state at
  every divergence point (postgres can never hold legacy data, so
  affected tables are empty when these run). All raw-DDL and PRAGMA
  migrations are now vendor-gated with sqlite behavior byte-for-byte
  unchanged.
- A pre_save clamp truncates CharField values to max_length: sqlite
  never enforced varchar(n) but postgres does (e.g. long crawl labels).
- Collation-sensitive URL range scans branch to escaped LIKE on postgres
  (with a text_pattern_ops index) since linguistic collations break
  bytewise range tricks; the crawl-config JSON search wave gets a
  jsonb-text implementation.

Verified on real PostgreSQL 16: fresh init applies the entire migration
graph, schema matches models exactly (column-level parity check +
makemigrations --check), and add/run/list/search/status/remove all work
end-to-end. New test_postgres_backend.py suite boots a real throwaway
postgres cluster (initdb + pg_ctl); CI workflows install postgres server
binaries.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019YHSjZM6TstSAMN2PhgfUg
2026-07-23 17:08:47 +00:00
..
migrations Add native PostgreSQL support alongside SQLite 2026-07-23 17:08:47 +00:00
__init__.py wip 2026-03-23 03:58:32 -07:00
admin.py release: archivebox 0.9.31rc42 2026-05-24 15:40:51 -07:00
apps.py wip 2026-03-23 03:58:32 -07:00
auth.py Publish local ArchiveBox changes 2026-06-02 02:25:52 -07:00
middleware.py wip 2026-03-23 03:58:32 -07:00
models.py Refactor plugins search progress and config flows 2026-06-01 00:08:27 -07:00
urls.py Exercise ArchiveBox through unified runtime lifecycles 2026-07-21 19:26:42 -07:00
v1_api.py Exercise ArchiveBox through unified runtime lifecycles 2026-07-21 19:26:42 -07:00
v1_auth.py wip 2026-03-23 03:58:32 -07:00
v1_cli.py Exercise ArchiveBox through unified runtime lifecycles 2026-07-21 19:26:42 -07:00
v1_core.py Route runtime binaries through abxpkg 2026-07-20 12:50:14 -07:00
v1_crawls.py Exercise ArchiveBox through unified runtime lifecycles 2026-07-21 19:26:42 -07:00
v1_machine.py wip 2026-03-23 03:58:32 -07:00
v1_personas.py Publish local ArchiveBox changes 2026-06-02 02:25:52 -07:00
webhooks.py release: archivebox 0.9.31rc41 2026-05-24 14:07:33 -07:00