-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd_display_settings.py
More file actions
47 lines (38 loc) · 1.37 KB
/
add_display_settings.py
File metadata and controls
47 lines (38 loc) · 1.37 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
"""
Migration script to add display settings table for QR code visibility controls
"""
import sqlite3
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
DATABASE_PATH = os.path.join(BASE_DIR, 'flask_app', 'database', 'fire_dept.db')
def add_display_settings_table():
"""Add display_settings table to store server-side display preferences"""
conn = sqlite3.connect(DATABASE_PATH)
cursor = conn.cursor()
print("🔧 Adding display_settings table...")
# Create display_settings table
cursor.execute('''
CREATE TABLE IF NOT EXISTS display_settings (
id INTEGER PRIMARY KEY AUTOINCREMENT,
setting_key TEXT UNIQUE NOT NULL,
setting_value TEXT NOT NULL,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
''')
print("✅ Created table: display_settings")
# Insert default settings for QR code visibility
default_settings = [
('show_inventory_qr', 'true'),
('show_maintenance_qr', 'true')
]
for key, value in default_settings:
cursor.execute('''
INSERT OR IGNORE INTO display_settings (setting_key, setting_value)
VALUES (?, ?)
''', (key, value))
print(f"✅ Added default setting: {key} = {value}")
conn.commit()
conn.close()
print("\n✅ Migration complete!")
if __name__ == '__main__':
add_display_settings_table()