The version in the name broke the required status check
when 3.14 became the `MAIN_VERSION`.
The timeout ensures the CI server stays ready
even when something goes badly wrong.
Without a configured version, `mypy` and `pyright`
check against the Python that runs them.
With `MAIN_PYTHON` at 3.14, they would accept
`stdlib` APIs and `typing` features new in 3.14.
Yet, `requires-python` promises 3.13;
so, the type checkers must flag such code.
`black` and `ruff` already target 3.13 for the same reason.
In the "sequentially" variant of the test database,
`current_db_revision()` must return the head of the migrations;
in the "all_at_once" variant, there is no version table.
The `@db_revision` decorator no longer runs `alembic current` in a subprocess,
which only worked from the project folder and reported any failure as a wrong revision.
Also, its docstring now explains that it locks completed stages of the data pipeline.
The column is of type `JSON`,
but the code stored a JSON-encoded string in it;
so, the data was encoded twice.
A later data migration converts the existing rows.
The global `db.session` is now a `scoped_session`,
like, for example, in Flask-SQLAlchemy.
Importing the package no longer creates an engine;
so, the placeholder for the tests is obsolete.
The `db_session` fixture replaces `db.session` with `monkeypatch`
such that it is reset after each test.
Tests without the fixture get a placeholder that fails loudly
instead of opening a real session,
which would block the `DROP SCHEMA` at the end of the test run.
`Session.query()` is the legacy API in SQLAlchemy 2.x.
`.one_or_none()` expresses that the unique constraint
on the five filtered columns allows at most one cached `Forecast`.
`Session.query()` is the legacy API in SQLAlchemy 2.x.
The addresses with restaurants are now selected with a subquery in one statement.
The `_restaurants_mock` fixture mocks the new call chain.
`Session.query()` is the legacy API in SQLAlchemy 2.x.
Unlike `Query`, `select()` does not deduplicate single entities from a `JOIN`;
so, `Grid.gridify()` calls `.unique()` explicitly.
The `addresses_mock` fixtures mock the new call chain.
The migrations create foreign keys from the `CLEAN_SCHEMA`
into the `ORIGINAL_SCHEMA` to ensure the cleaned data still
refer to the original data.
The ORM models do not know the original tables.
Also, print the `diff` as indented JSON.
Before version 14, PostgreSQL stored `EXTRACT(...)` as `date_part(...)`,
and the rendering of `IN (...)` changed as well.
The checks created in 2021 express the same rules as the ORM models
but render differently. See the docstring of the migration for details.
Earlier migrations named some constraints without `op.f()`,
a column rename did not rename the unique constraint containing the column,
and the "ordered_timestamps_N" checks in "orders" were shifted by one
compared to the ORM.
See the docstring of the migration for details.
`ReplaySimulation`, `ReplayedOrder`, and `Forecast` accessed
relationships in their `.__repr__()`, which emits queries
or fails for detached instances.
They now use the foreign key columns.
The ORM always defined `Grid.side_length` with `nullable=False`,
but the migration that created the "grids" table did not; the
live database contains no `NULL`s.
The "Revision" and "Revises" lines and the revision hashes in `upgrade()`
and `downgrade()` repeated the `revision` and `down_revision` variables;
the creation date is in the file name.
The `unique=True` on `Grid.side_length`
made the side length unique across all cities.
The intended rule is the `UniqueConstraint("city_id", "side_length")`,
which the migrations already implement; so, no migration is needed.
The new "verify-db-objects" session creates the ORM objects
with `.create_all()` in a temporary database and compares
them with the `CLEAN_SCHEMA` of a "live" database using `sqlalchemy-diff`