feat: switch all timezone naive datetimes to timezone aware
This commit is contained in:
parent
41fc0a73a5
commit
e22abb383c
30 changed files with 322 additions and 226 deletions
|
@ -1,6 +1,6 @@
|
|||
import enum
|
||||
from datetime import datetime
|
||||
from typing import List
|
||||
from datetime import datetime, timezone
|
||||
from typing import List, Optional
|
||||
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
|
@ -37,12 +37,12 @@ class BridgeConf(AbstractConfiguration):
|
|||
)
|
||||
|
||||
def destroy(self) -> None:
|
||||
self.destroyed = datetime.utcnow()
|
||||
self.updated = datetime.utcnow()
|
||||
self.destroyed = datetime.now(tz=timezone.utc)
|
||||
self.updated = datetime.now(tz=timezone.utc)
|
||||
for bridge in self.bridges:
|
||||
if bridge.destroyed is None:
|
||||
bridge.destroyed = datetime.utcnow()
|
||||
bridge.updated = datetime.utcnow()
|
||||
bridge.destroyed = datetime.now(tz=timezone.utc)
|
||||
bridge.updated = datetime.now(tz=timezone.utc)
|
||||
|
||||
@classmethod
|
||||
def csv_header(cls) -> List[str]:
|
||||
|
@ -52,13 +52,13 @@ class BridgeConf(AbstractConfiguration):
|
|||
|
||||
|
||||
class Bridge(AbstractResource):
|
||||
conf_id = db.Column(db.Integer, db.ForeignKey("bridge_conf.id"), nullable=False)
|
||||
cloud_account_id = db.Column(db.Integer, db.ForeignKey("cloud_account.id"))
|
||||
terraform_updated = db.Column(db.DateTime(), nullable=True)
|
||||
nickname = db.Column(db.String(255), nullable=True)
|
||||
fingerprint = db.Column(db.String(255), nullable=True)
|
||||
hashed_fingerprint = db.Column(db.String(255), nullable=True)
|
||||
bridgeline = db.Column(db.String(255), nullable=True)
|
||||
conf_id: Mapped[int] = mapped_column(db.ForeignKey("bridge_conf.id"))
|
||||
cloud_account_id: Mapped[int] = mapped_column(db.ForeignKey("cloud_account.id"))
|
||||
terraform_updated: Mapped[Optional[datetime]] = mapped_column(db.DateTime(timezone=True), nullable=True)
|
||||
nickname: Mapped[Optional[str]]
|
||||
fingerprint: Mapped[Optional[str]]
|
||||
hashed_fingerprint: Mapped[Optional[str]]
|
||||
bridgeline: Mapped[Optional[str]]
|
||||
|
||||
conf = db.relationship("BridgeConf", back_populates="bridges")
|
||||
cloud_account = db.relationship("CloudAccount", back_populates="bridges")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue