Add requirements.txt and guard app model imports in env.py

requirements.txt copied from shared_lib for Docker build compatibility.
Alembic env.py now uses try/except for app-specific model imports so
upgrade head works in Docker where only one app's code is present.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
giles
2026-02-11 13:16:04 +00:00
parent ef806f8fbb
commit 4dd25526b9
2 changed files with 52 additions and 4 deletions

View File

@@ -19,10 +19,11 @@ from shared.db.base import Base
# Import ALL models so Base.metadata sees every table
import shared.models # noqa: F401 User, KV, MagicLink, MenuItem, Ghost*
import blog.models # noqa: F401 Post, Author, Tag, Snippet, TagGroup
import market.models # noqa: F401 Product, CartItem, MarketPlace, etc.
import cart.models # noqa: F401 Order, OrderItem, PageConfig
import events.models # noqa: F401 Calendar, CalendarEntry, Ticket, etc.
for _mod in ("blog.models", "market.models", "cart.models", "events.models"):
try:
__import__(_mod)
except ImportError:
pass # OK in Docker — only needed for autogenerate
target_metadata = Base.metadata