1- from datetime import datetime , date
1+ from datetime import datetime , date , timezone
22from flask_login import UserMixin
33from werkzeug .security import generate_password_hash , check_password_hash
44from app import db , login_manager
@@ -62,7 +62,7 @@ class Webhook(db.Model):
6262 custom_headers = db .Column (db .Text ) # JSON string for custom headers
6363 is_active = db .Column (db .Boolean , default = True )
6464 user_id = db .Column (db .Integer , db .ForeignKey ('user.id' ), nullable = False )
65- created_at = db .Column (db .DateTime , default = datetime .utcnow )
65+ created_at = db .Column (db .DateTime , default = lambda : datetime .now ( timezone . utc ) )
6666 last_used = db .Column (db .DateTime )
6767
6868 # Relationship
@@ -106,7 +106,7 @@ class ExchangeRate(db.Model):
106106 base_currency = db .Column (db .String (3 ), nullable = False , default = 'EUR' )
107107 provider = db .Column (db .String (40 ), nullable = False , default = 'legacy' ) # data source identifier
108108 rates_json = db .Column (db .Text , nullable = False ) # JSON string of exchange rates
109- created_at = db .Column (db .DateTime , default = datetime .utcnow )
109+ created_at = db .Column (db .DateTime , default = lambda : datetime .now ( timezone . utc ) )
110110
111111 __table_args__ = (
112112 db .UniqueConstraint ('date' , 'base_currency' , 'provider' , name = 'uq_rate_date_base_provider' ),
@@ -136,7 +136,7 @@ def save_rates(cls, rates, base_currency='EUR', provider='unknown'):
136136 existing_rate = cls .query .filter_by (date = today , base_currency = base_currency , provider = provider ).first ()
137137 if existing_rate :
138138 existing_rate .rates_json = json .dumps (rates )
139- existing_rate .created_at = datetime .utcnow ( )
139+ existing_rate .created_at = datetime .now ( timezone . utc )
140140 else :
141141 new_rate = cls (
142142 date = today ,
@@ -154,7 +154,7 @@ class PaymentMethod(db.Model):
154154 last_four = db .Column (db .String (4 ), nullable = True )
155155 notes = db .Column (db .Text , nullable = True )
156156 user_id = db .Column (db .Integer , db .ForeignKey ('user.id' ), nullable = False )
157- created_at = db .Column (db .DateTime , default = datetime .utcnow )
157+ created_at = db .Column (db .DateTime , default = lambda : datetime .now ( timezone . utc ) )
158158
159159 # Relationship back to user
160160 user = db .relationship ('User' , backref = db .backref ('payment_methods' , lazy = True ))
0 commit comments