Add an opt-in PostgreSQL backend for the webtiles user database - #1
Merged
Conversation
Large or multi-host webtiles deployments need one shared account database,
which the per-server SQLite files cannot provide. This adds a second backend
behind the same userdb.py function surface, selected with
userdb_backend = "postgresql" and userdb_dsn. The default stays SQLite and
servers that do not set the new options are unaffected; psycopg is imported
only when the backend is selected and ships as an optional requirements file.
The existing SQLite queries are rewritten at execute time (pg_sql):
placeholders, the COLLATE NOCASE/RTRIM clauses (citext columns provide the
case-insensitive matching and unique usernames), datetime('now') forms, and
the mutesettings upsert. Schema is created on first start with IF NOT EXISTS.
userdb_test.py reruns the whole UserDBTest suite against a live server when
WEBTILES_TEST_POSTGRESQL_DSN is set, plus unit tests for the rewrite rules
that always run.
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.
Large or multi-host webtiles deployments need one shared account database, which the per-server SQLite files cannot provide. This adds a second backend behind the same
userdb.pyfunction surface, selected withuserdb_backend = "postgresql"anduserdb_dsn.psycopgis imported only when the backend is selected and ships as an optional requirements file (requirements/postgresql.py3.txt).pg_sql): placeholders,COLLATE NOCASE/RTRIM(citext columns provide case-insensitive matching and unique usernames),datetime('now')forms, and the mutesettings upsert.IF NOT EXISTS.userdb_test.pyreruns the wholeUserDBTestsuite against a live server whenWEBTILES_TEST_POSTGRESQL_DSNis set, plus always-on unit tests for the rewrite rules.https://claude.ai/code/session_012epLj7mVTpcFaVNi8C8iy3