Add MariaDB and PostgreSQL database provider support - #423
Open
bauerpawel wants to merge 4 commits into
Open
bauerpawel wants to merge 4 commits into
bauerpawel wants to merge 4 commits into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds MariaDB/MySQL and PostgreSQL as database backends, alongside the existing SQLite and Redis providers. Both implement
dbabstraction.Databasevia 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.internal/configuration/database/provider/mariadb,internal/configuration/database/provider/postgresmariadb://andpostgres://schemes, plus adatabase namefield onDbConnectiondatabase.Migrate()(used by--migrate-db) already worked generically via theDatabaseinterface, but the CLI's status-linegetType()helper didn't know about the two new types and printed "Invalid" — fixed, and the existing test's expectation was updated accordinglymake test-mariadb/make test-postgrestargets to run each provider's test suite against a real, disposable database (no in-process mock exists for either engine, so these are gated behindmariadbtest/postgrestestbuild tags and excluded from CI, matching the existingawstestconvention)mariadb://andpostgres://URL schemes inadvanced.rst, which previously only mentionedsqlite://andredis://.gitignoreentry 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
Technical Details
Databaseprovider implementations (MariaDB/MySQL, PostgreSQL); no changes to existing providers or their schemas.How Has This Been Tested?
--migrate-dbround-trips data correctly between all four supported database types.go test ./... --tags=test,awsmock(full suite passes;mariadbtest/postgrestest-tagged tests run separately viamake test-mariadb/make test-postgresagainst real servers)Checklist
🤖 Generated with Claude Code
https://claude.ai/code/session_0168YUwGEzEHTqd9CwzXE53d