"""Shared test adaptations for the production PostgreSQL schema.""" import re from pathlib import Path import pytest @pytest.fixture(scope="session") def sqlite_schema() -> str: """Keep PostgreSQL DDL authoritative; adapt JSON storage and clock for SQLite. SQLite stores serialized JSON as text. These tests exercise schema and INSERT semantics, not PostgreSQL JSONB operators or TimescaleDB behavior. """ schema = (Path(__file__).resolve().parents[1] / "db" / "schema.sql").read_text( encoding="utf-8" ) schema = re.sub(r"::jsonb\b", "", schema) schema = re.sub(r"\bjsonb\b", "text", schema) return schema.replace("DEFAULT now()", "DEFAULT CURRENT_TIMESTAMP")