Keep the engine's state in SQLite, not Postgres
One process owns this database — the image has run a single uvicorn worker for that reason since the four-engines bug — so a file beside the flows is the honest shape for it, and it is what lets `fluksio serve` need no infrastructure at all. Live values, node execution and the work queue never came here anyway; what does is a rollup a minute at a time, a row per cascade and the run history, and WAL keeps the readers going while that one writer works. DATA_DIR is now the one setting that moves everything an installation keeps; the rest derive from it and the images still spell theirs out. The schema is prepared in-process at startup, so the prestart service is gone, and the ten Postgres-only revisions collapse into one portable baseline. Three things only worked because psycopg was casting for us: a token's subject arriving as a string where the column is a UUID, `greatest`, and `date_bin`. The timestamps needed a column type of their own — SQLite stores no offset, and a naive datetime read back either raises against an aware `now` or serialises as local time. Postgres stays in the stack only for Umami, behind the analytics profile. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import uuid
|
||||
from collections.abc import Generator
|
||||
from typing import Annotated, Any
|
||||
|
||||
@@ -157,7 +158,16 @@ def _user_for(session: Session, token_data: TokenPayload) -> User | None:
|
||||
return session.exec(
|
||||
select(User).where(User.portal_sub == token_data.portal_sub)
|
||||
).first()
|
||||
return session.get(User, token_data.sub) if token_data.sub else None
|
||||
if not token_data.sub:
|
||||
return None
|
||||
try:
|
||||
# The subject is a string on the wire. Postgres cast it on the way in;
|
||||
# nothing else does, so parse it here rather than hand a driver a
|
||||
# string where it wants a UUID.
|
||||
user_id = uuid.UUID(token_data.sub)
|
||||
except ValueError:
|
||||
return None
|
||||
return session.get(User, user_id)
|
||||
|
||||
|
||||
def user_from_token(
|
||||
|
||||
Reference in New Issue
Block a user