Fix DB Model.
This commit is contained in:
20
migrations/add_time_preferences.sql
Normal file
20
migrations/add_time_preferences.sql
Normal file
@@ -0,0 +1,20 @@
|
||||
-- Add time formatting and rounding preferences to user_preferences table
|
||||
-- These columns support user-specific time display and rounding settings
|
||||
|
||||
-- Add time formatting preference (24h vs 12h)
|
||||
ALTER TABLE user_preferences
|
||||
ADD COLUMN IF NOT EXISTS time_format_24h BOOLEAN DEFAULT TRUE;
|
||||
|
||||
-- Add time rounding preference (0, 5, 10, 15, 30, 60 minutes)
|
||||
ALTER TABLE user_preferences
|
||||
ADD COLUMN IF NOT EXISTS time_rounding_minutes INTEGER DEFAULT 0;
|
||||
|
||||
-- Add rounding direction preference (false=round down, true=round to nearest)
|
||||
ALTER TABLE user_preferences
|
||||
ADD COLUMN IF NOT EXISTS round_to_nearest BOOLEAN DEFAULT FALSE;
|
||||
|
||||
-- Update existing date_format column default if needed
|
||||
-- (The column should already exist, but let's ensure the default is correct)
|
||||
UPDATE user_preferences
|
||||
SET date_format = 'ISO'
|
||||
WHERE date_format = 'YYYY-MM-DD' OR date_format IS NULL;
|
||||
@@ -1,7 +1,8 @@
|
||||
-- Remove all email preference columns from user_preferences table
|
||||
-- These columns were not being used and are being removed to clean up the schema
|
||||
-- Remove unused columns from user_preferences table
|
||||
-- These columns were defined in the model but never used in the application
|
||||
|
||||
ALTER TABLE user_preferences
|
||||
DROP COLUMN IF EXISTS email_daily_summary,
|
||||
DROP COLUMN IF EXISTS email_notifications,
|
||||
DROP COLUMN IF EXISTS email_weekly_summary;
|
||||
DROP COLUMN IF EXISTS email_weekly_summary,
|
||||
DROP COLUMN IF EXISTS default_project_id;
|
||||
@@ -19,6 +19,7 @@ POSTGRES_MIGRATIONS = [
|
||||
'postgres_only_migration.py', # Main migration from commit 4214e88 onward
|
||||
'add_note_sharing.sql', # Add note sharing functionality
|
||||
'remove_email_preferences.sql', # Remove unused email preference columns
|
||||
'add_time_preferences.sql', # Add time formatting and rounding preferences
|
||||
]
|
||||
|
||||
|
||||
|
||||
@@ -153,11 +153,13 @@ class UserPreferences(db.Model):
|
||||
theme = db.Column(db.String(20), default='light')
|
||||
language = db.Column(db.String(10), default='en')
|
||||
timezone = db.Column(db.String(50), default='UTC')
|
||||
date_format = db.Column(db.String(20), default='YYYY-MM-DD')
|
||||
date_format = db.Column(db.String(20), default='ISO') # ISO, US, German, etc.
|
||||
time_format = db.Column(db.String(10), default='24h')
|
||||
time_format_24h = db.Column(db.Boolean, default=True) # True for 24h, False for 12h
|
||||
|
||||
# Time tracking preferences
|
||||
default_project_id = db.Column(db.Integer, db.ForeignKey('project.id'), nullable=True)
|
||||
time_rounding_minutes = db.Column(db.Integer, default=0) # 0, 5, 10, 15, 30, 60
|
||||
round_to_nearest = db.Column(db.Boolean, default=False) # False=round down, True=round to nearest
|
||||
timer_reminder_enabled = db.Column(db.Boolean, default=True)
|
||||
timer_reminder_interval = db.Column(db.Integer, default=60) # Minutes
|
||||
|
||||
@@ -169,7 +171,6 @@ class UserPreferences(db.Model):
|
||||
|
||||
# Relationships
|
||||
user = db.relationship('User', backref=db.backref('preferences', uselist=False))
|
||||
default_project = db.relationship('Project')
|
||||
|
||||
|
||||
class UserDashboard(db.Model):
|
||||
|
||||
Reference in New Issue
Block a user