Review
Managed Postgres bootstrap for GlazeKiln kiln slots
Ceramic co-op cutover: stop the SQLite file on the kiln-room NUC and point GlazeKiln at managed Postgres so multi-studio schedules share one DB. PR adds create_engine from DATABASE_URL plus a startup log line so deploys can confirm which host/env we attached to.
SQLAlchemyTier 1securitysqlalchemyloggingsecrets
Click a line to flag it, pick one or more labels, then submit. If the change looks correct, approve it.
glazekiln/db.py+4-2
| 1 | 1 | import logging | |
| 2 | 2 | import os | |
| 3 | 3 | ||
| 4 | 4 | from sqlalchemy import create_engine | |
| 5 | 5 | from sqlalchemy.orm import sessionmaker | |
| 6 | 6 | ||
| 7 | 7 | logger = logging.getLogger(__name__) | |
| 8 | 8 | ||
| 9 | - | # Local NUC store; each studio ships its own kiln.db volume. | |
| 10 | - | engine = create_engine("sqlite:////var/glazekiln/kiln.db", future=True) | |
| 9 | + | DATABASE_URL = os.environ["DATABASE_URL"] | |
| 10 | + | # Log the URL at boot so on-call can see which cluster this pod hit. | |
| 11 | + | logger.info("creating sqlalchemy engine url=%s", DATABASE_URL) | |
| 12 | + | engine = create_engine(DATABASE_URL, pool_pre_ping=True, future=True) | |
| 11 | 13 | SessionLocal = sessionmaker(bind=engine, autoflush=False, autocommit=False) | |
| 12 | 14 | ||
| 13 | 15 | ||
| 14 | 16 | def get_session(): | |
| 15 | 17 | db = SessionLocal() | |
| 16 | 18 | try: | |
| 17 | 19 | yield db | |
| 18 | 20 | finally: | |
| 19 | 21 | db.close() |