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:
@@ -3,12 +3,15 @@
|
||||
import base64
|
||||
import hashlib
|
||||
import secrets
|
||||
import uuid
|
||||
from urllib.parse import parse_qs, urlparse
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import Session, select
|
||||
|
||||
from fluksio.core.config import settings
|
||||
from fluksio.models import OAuthRefreshToken
|
||||
|
||||
PREFIX = f"{settings.API_V1_STR}/oauth"
|
||||
REDIRECT = "http://127.0.0.1:41234/callback"
|
||||
@@ -235,6 +238,7 @@ def test_everything_is_refused_while_mcp_is_off(
|
||||
|
||||
def test_one_agent_can_be_revoked_without_touching_the_others(
|
||||
client: TestClient,
|
||||
db: Session,
|
||||
superuser_token_headers: dict[str, str],
|
||||
normal_user_token_headers: dict[str, str],
|
||||
) -> None:
|
||||
@@ -272,3 +276,13 @@ def test_one_agent_can_be_revoked_without_touching_the_others(
|
||||
data={"grant_type": "refresh_token", "refresh_token": tokens["refresh_token"]},
|
||||
)
|
||||
assert refreshed.status_code == 400
|
||||
|
||||
# Went, rather than merely stopped working: nothing here deletes those rows
|
||||
# itself, so an orphan is a foreign key the database is not enforcing —
|
||||
# which SQLite does not do unless it is asked (`PRAGMA foreign_keys`).
|
||||
left = db.exec(
|
||||
select(OAuthRefreshToken).where(
|
||||
OAuthRefreshToken.client_id == uuid.UUID(client_id)
|
||||
)
|
||||
).all()
|
||||
assert left == []
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import uuid
|
||||
|
||||
import pytest
|
||||
from fastapi.testclient import TestClient
|
||||
from sqlmodel import Session, select
|
||||
@@ -20,7 +22,8 @@ def test_create_user(client: TestClient, db: Session) -> None:
|
||||
|
||||
data = r.json()
|
||||
|
||||
user = db.exec(select(User).where(User.id == data["id"])).first()
|
||||
# The id comes back from JSON as a string, and the column is a UUID.
|
||||
user = db.exec(select(User).where(User.id == uuid.UUID(data["id"]))).first()
|
||||
|
||||
assert user
|
||||
assert user.email == "pollo@listo.com"
|
||||
|
||||
Reference in New Issue
Block a user