Yash030 Claude Opus 4.7 commited on
Commit
c23ccf2
·
1 Parent(s): 4b16ae5

feat: auto-migrate legacy state_store.db to Dolt SQL on first boot

Browse files

Runs import_data.py once after Dolt starts if state_store.db exists
and migration hasn't run yet. Writes .migration_done sentinel to skip
on subsequent restarts.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

Files changed (1) hide show
  1. start.sh +15 -0
start.sh CHANGED
@@ -64,6 +64,21 @@ dolt sql-server --host 127.0.0.1 --port 3306 --data-dir /home/user/.agentmemory/
64
  echo "[start] Waiting for Dolt server to be ready..."
65
  sleep 5
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  # Set the port for Flask application to run on (Hugging Face Space expects 7860)
68
  export PORT=7860
69
  export III_REST_PORT=7860
 
64
  echo "[start] Waiting for Dolt server to be ready..."
65
  sleep 5
66
 
67
+ # One-time migration: import legacy state_store.db binary files into Dolt SQL
68
+ STATE_STORE="/home/user/.agentmemory/state_store.db"
69
+ MIGRATION_DONE="/home/user/.agentmemory/.migration_done"
70
+ if [ -d "$STATE_STORE" ] && [ ! -f "$MIGRATION_DONE" ]; then
71
+ echo "[start] Found legacy state_store.db — running one-time migration to Dolt SQL..."
72
+ python3 -c "
73
+ import sys, os
74
+ sys.path.insert(0, '/app/src')
75
+ from db import StateKV
76
+ from import_data import import_old_data
77
+ kv = StateKV()
78
+ import_old_data('$STATE_STORE', kv)
79
+ " && touch "$MIGRATION_DONE" && echo "[start] Migration complete."
80
+ fi
81
+
82
  # Set the port for Flask application to run on (Hugging Face Space expects 7860)
83
  export PORT=7860
84
  export III_REST_PORT=7860