Docker and more calendar work
This commit is contained in:
parent
4527504c80
commit
f7a919ebf2
22 changed files with 2036 additions and 79 deletions
37
migrations/add_calendar_settings.py
Normal file
37
migrations/add_calendar_settings.py
Normal file
|
@ -0,0 +1,37 @@
|
|||
"""
|
||||
Migration script to add calendar-related fields to the settings table.
|
||||
"""
|
||||
import sqlite3
|
||||
from flask import current_app
|
||||
|
||||
def run_migration():
|
||||
"""
|
||||
Run the migration to add calendar-related fields to the settings table.
|
||||
"""
|
||||
# Get the database path from the app config
|
||||
db_path = current_app.config['SQLALCHEMY_DATABASE_URI'].replace('sqlite:///', '')
|
||||
|
||||
# Connect to the database
|
||||
conn = sqlite3.connect(db_path)
|
||||
cursor = conn.cursor()
|
||||
|
||||
# Check if the columns already exist in the settings table
|
||||
cursor.execute("PRAGMA table_info(settings)")
|
||||
columns = [column[1] for column in cursor.fetchall()]
|
||||
|
||||
# Add the calendar_first_day column if it doesn't exist
|
||||
if 'calendar_first_day' not in columns:
|
||||
print("Adding 'calendar_first_day' column to settings table...")
|
||||
cursor.execute("ALTER TABLE settings ADD COLUMN calendar_first_day TEXT DEFAULT 'Monday'")
|
||||
|
||||
# Add the calendar_show_monitored_only column if it doesn't exist
|
||||
if 'calendar_show_monitored_only' not in columns:
|
||||
print("Adding 'calendar_show_monitored_only' column to settings table...")
|
||||
cursor.execute("ALTER TABLE settings ADD COLUMN calendar_show_monitored_only BOOLEAN DEFAULT 0")
|
||||
|
||||
# Commit the changes and close the connection
|
||||
conn.commit()
|
||||
conn.close()
|
||||
|
||||
print("Calendar settings migration completed successfully!")
|
||||
return True
|
Loading…
Add table
Add a link
Reference in a new issue