Migrate db to connect logs to service. Deleted any previous logs as they are useless

This commit is contained in:
2025-09-03 16:44:27 +02:00
parent 9908683e45
commit dea5278731
2 changed files with 60 additions and 2 deletions

View File

@@ -1,12 +1,18 @@
from mem import db
from datetime import datetime, timezone
from validators import url as is_url
from typing import Any
from typing import Any, Optional
class log(db.Model):
id: int = db.Column(db.Integer, primary_key=True)
dateCreated: datetime = db.Column(db.DateTime, nullable=False)
dateCreated: datetime = db.Column(db.DateTime, nullable=False, index=True)
service_id: int = db.Column(
db.Integer,
db.ForeignKey("service.id"),
nullable=False,
)
ping: Optional[int] = db.Column(db.Integer, nullable=True)
def __init__(self):
super().__init__()
@@ -21,6 +27,8 @@ class service(db.Model):
public_access: bool = db.Column(db.Boolean, nullable=False)
ping_method: int = db.Column(db.Integer, nullable=False)
logs = db.relationship("log")
def __init__(
self, url: str, label: str, public_access: bool, ping_method: int
):