Skip to content

Add MariaDB and PostgreSQL database provider support - #423

Open
bauerpawel wants to merge 4 commits into
Forceu:masterfrom
bauerpawel:feat/mariadb-postgres-support
Open

bauerpawel wants to merge 4 commits into
Forceu:masterfrom
bauerpawel:feat/mariadb-postgres-support

Conversation

@bauerpawel

Copy link
Copy Markdown
Contributor

Description

Adds MariaDB/MySQL and PostgreSQL as database backends, alongside the existing SQLite and Redis providers. Both implement dbabstraction.Database via pure-Go, CGO-free drivers (go-sql-driver/mysql, jackc/pgx/v5), track their own schema version, and create their tables on first connect — no separate migration tooling needed.

  • New providers: internal/configuration/database/provider/mariadb, internal/configuration/database/provider/postgres
  • Setup wizard: new form fields, JS toggling, and URL parsing for the mariadb:// and postgres:// schemes, plus a database name field on DbConnection
  • database.Migrate() (used by --migrate-db) already worked generically via the Database interface, but the CLI's status-line getType() helper didn't know about the two new types and printed "Invalid" — fixed, and the existing test's expectation was updated accordingly
  • make test-mariadb / make test-postgres targets to run each provider's test suite against a real, disposable database (no in-process mock exists for either engine, so these are gated behind mariadbtest/postgrestest build tags and excluded from CI, matching the existing awstest convention)
  • Documents the mariadb:// and postgres:// URL schemes in advanced.rst, which previously only mentioned sqlite:// and redis://
  • .gitignore entry for a local test-credentials file used for live testing against real servers (never committed)

Verified live against real MariaDB 11.8 and PostgreSQL 17 servers, including a full migration round trip (SQLite → MariaDB → PostgreSQL → SQLite) that preserved users, E2E info, API keys, file metadata, hotlinks, and file requests at every hop.

Type of Change

  • New feature (non-breaking change which adds functionality)

Technical Details

  • Database changes: Yes — adds two new Database provider implementations (MariaDB/MySQL, PostgreSQL); no changes to existing providers or their schemas.
  • Storage backend affected: No
  • Usage of AI: Yes — developed with Claude Code as a pair-programming assistant (provider implementations, setup wizard wiring, tests, docs). I reviewed and tested all changes, including live verification against real MariaDB/PostgreSQL servers, before submitting.

How Has This Been Tested?

  • Manual Testing: Ran the setup wizard against real MariaDB 11.8 and PostgreSQL 17 servers; verified --migrate-db round-trips data correctly between all four supported database types.
  • Unit Tests: go test ./... --tags=test,awsmock (full suite passes; mariadbtest/postgrestest-tagged tests run separately via make test-mariadb/make test-postgres against real servers)
  • Environment: Windows 11

Checklist

  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.

🤖 Generated with Claude Code

https://claude.ai/code/session_0168YUwGEzEHTqd9CwzXE53d

bauerpawel and others added 4 commits September 9, 2026 14:13
Implements dbabstraction.Database for MariaDB/MySQL and PostgreSQL via
the pure-Go, CGO-free go-sql-driver/mysql and jackc/pgx/v5 drivers,
alongside the existing sqlite/redis providers. Each provider tracks its
own schema version and creates its tables on first connect.

Wires the new types through the setup wizard (new form fields, JS
toggling, URL parsing for the mariadb:// and postgres:// schemes),
adds a `database name` field to DbConnection, and adds `make
test-mariadb`/`make test-postgres` targets to run each provider's test
suite against a real, disposable database (no in-process mock exists
for either engine, so these are gated behind mariadbtest/postgrestest
build tags and excluded from CI). Verified against real MariaDB 11.8
and PostgreSQL 17 servers.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019woTYJGrS4pfPWC6CCgffQ
test_debian13.txt held plaintext SSH credentials for a private
Proxmox LXC used to verify the MariaDB/PostgreSQL providers against
real servers. It has been deleted; ignore the name so it can be
recreated locally for future live testing without risk of committing
it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019woTYJGrS4pfPWC6CCgffQ
database.Migrate() already worked generically for any pair of database
types via the dbabstraction.Database interface, but the migrate-database
CLI's getType() helper (used only for the printed status line) didn't
know about TypeMariaDb/TypePostgres and printed "Invalid" for either -
and the existing test asserted that as expected behavior. Also documents
the mariadb:// and postgres:// URL schemes in advanced.rst, which
previously claimed only sqlite:// and redis:// were valid.

Verified live: a full round trip (SQLite -> MariaDB -> PostgreSQL ->
SQLite) against real MariaDB/PostgreSQL servers preserved users, E2E
info, API keys, file metadata, hotlinks, and file requests at every hop.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019woTYJGrS4pfPWC6CCgffQ
Resolves go.mod/go.sum conflicts between master's dependency bumps
and this branch's added MariaDB/PostgreSQL indirect dependencies
(golang.org/x/text, x/exp, x/tools): keeps this branch's extra
indirect deps and takes master's newer versions of the shared ones.

Verified go generate, go build, go vet (test/noaws/awsmock tags) and
go test --tags=test,awstest all succeed after the merge; the
remaining local test failures are pre-existing Windows-only
environment issues (path separators, file locks) reproduced
identically on unmodified upstream/master.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JWZJU5aSCEBB9DHBWvL4t4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant