From ec08c185aa3d921876269cb6f374f83366f8305d Mon Sep 17 00:00:00 2001 From: Leo Vasanko Date: Fri, 7 Aug 2026 00:08:50 +0000 Subject: [PATCH] Demo: use the script itself as the migrations module --- demo/main.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/demo/main.py b/demo/main.py index cab1588..a0b2135 100644 --- a/demo/main.py +++ b/demo/main.py @@ -10,9 +10,9 @@ lives in this file. import asyncio import logging +import sys from datetime import UTC, datetime, timedelta from pathlib import Path -from types import ModuleType import msgspec @@ -44,13 +44,10 @@ def migrate_v1(d: dict) -> None: d["settings"] = {"theme": "dark"} -migrations = ModuleType("demo_migrations") -migrations.migrate_v1 = migrate_v1 - # Phase 1 instance: default logging, original schema. kanta_v0 = Kanta(DB, DataV1()) -# Phase 2 instance: migrations and a custom log header. -kanta_v1 = Kanta(DB, Data(), migrations=migrations) +# Phase 2 instance: migrations (scanned from this script) and a custom header. +kanta_v1 = Kanta(DB, Data(), migrations=sys.modules[__name__]) _now = datetime(2026, 8, 6, tzinfo=UTC)