Skip to content

Commit 7590851

Browse files
fix(ci): apply base schema before migrations on fresh DB
_connect() only called migrate() on a new database, but migrations assume the base tables (sessions, messages, etc.) already exist. Apply schema.sql first, matching the pattern in init_db(). This was the root cause of all UAT failures: start_study_session() returned None because migration v1 failed with "no such table: sessions". Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 967895c commit 7590851

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎packages/studyctl/src/studyctl/history/_connection.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,13 @@ def _connect():
3636

3737
if is_new:
3838
try:
39+
from agent_session_tools.export_sessions import SCHEMA_FILE
3940
from agent_session_tools.migrations import migrate
4041

42+
# Apply base schema first — migrations assume tables exist
43+
with open(SCHEMA_FILE) as f:
44+
conn.executescript(f.read())
45+
4146
migrate(conn)
4247
logger.info("Created sessions DB at %s", db)
4348
except ImportError:

0 commit comments

Comments
 (0)