feat: Add turtle state persistence table for reconnect recovery
This commit is contained in:
@@ -7,6 +7,9 @@ const __dirname = path.dirname(__filename);
|
|||||||
|
|
||||||
const db = new Database(path.join(__dirname, 'turtle_control.db'));
|
const db = new Database(path.join(__dirname, 'turtle_control.db'));
|
||||||
|
|
||||||
|
// Enable WAL journal mode for better concurrent read/write performance
|
||||||
|
db.pragma('journal_mode = WAL');
|
||||||
|
|
||||||
// Initialize database schema
|
// Initialize database schema
|
||||||
export function initializeDatabase() {
|
export function initializeDatabase() {
|
||||||
// Turtle homes table
|
// Turtle homes table
|
||||||
@@ -185,6 +188,16 @@ export function initializeDatabase() {
|
|||||||
ON chunks(x, z);
|
ON chunks(x, z);
|
||||||
`);
|
`);
|
||||||
|
|
||||||
|
// Turtle state persistence table (for reconnect recovery)
|
||||||
|
db.exec(`
|
||||||
|
CREATE TABLE IF NOT EXISTS turtle_state (
|
||||||
|
turtle_id INTEGER PRIMARY KEY,
|
||||||
|
state_name TEXT NOT NULL,
|
||||||
|
state_data TEXT DEFAULT '{}',
|
||||||
|
updated_at INTEGER NOT NULL
|
||||||
|
)
|
||||||
|
`);
|
||||||
|
|
||||||
console.log('✅ Database initialized');
|
console.log('✅ Database initialized');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user