You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

29 lines
678 B

from __future__ import annotations
from datetime import datetime
from typing import ClassVar
from sqlalchemy import BigInteger, DateTime, Integer, func
from sqlalchemy.orm import Mapped, mapped_column
from app.extensions import db
ID_TYPE = BigInteger().with_variant(Integer, "sqlite")
class TimestampMixin:
created_at: Mapped[datetime] = mapped_column(
DateTime,
nullable=False,
server_default=func.now(),
)
updated_at: Mapped[datetime] = mapped_column(
DateTime,
nullable=False,
server_default=func.now(),
onupdate=func.now(),
)
class BaseModel(db.Model):
__abstract__: ClassVar[bool] = True