forked from karpathy/reader3
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmigrate_progress.py
More file actions
34 lines (29 loc) · 969 Bytes
/
Copy pathmigrate_progress.py
File metadata and controls
34 lines (29 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
"""
Migration script to add scroll_position column to reading_progress table.
"""
import sqlite3
import os
db_path = os.getenv("DATABASE_PATH", "reader_data.db")
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
try:
# Check if column exists
cursor.execute("PRAGMA table_info(reading_progress)")
columns = [row[1] for row in cursor.fetchall()]
if 'scroll_position' not in columns:
print("Adding scroll_position column...")
cursor.execute("""
ALTER TABLE reading_progress
ADD COLUMN scroll_position INTEGER DEFAULT 0
""")
conn.commit()
print("✓ Migration completed successfully!")
else:
print("✓ Column already exists, no migration needed.")
except sqlite3.OperationalError as e:
if "no such table" in str(e):
print("Table doesn't exist yet, will be created on first run.")
else:
print(f"Error: {e}")
finally:
conn.close()