24 lines
867 B
Python
24 lines
867 B
Python
from __future__ import annotations
|
|
|
|
from datetime import datetime
|
|
from typing import Optional
|
|
|
|
from sqlalchemy import DateTime, String, Text, UniqueConstraint, text
|
|
from sqlalchemy.dialects.mysql import BIGINT
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
|
|
from backend.db.base import Base
|
|
|
|
|
|
class Setting(Base):
|
|
__tablename__ = "settings"
|
|
__table_args__ = (UniqueConstraint("k", name="uniq_settings_key"),)
|
|
|
|
id: Mapped[int] = mapped_column(BIGINT(unsigned=True), primary_key=True, autoincrement=True)
|
|
k: Mapped[str] = mapped_column(String(128), nullable=False)
|
|
v: Mapped[Optional[str]] = mapped_column(Text)
|
|
description: Mapped[Optional[str]] = mapped_column(String(255))
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime, server_default=text("CURRENT_TIMESTAMP"), onupdate=text("CURRENT_TIMESTAMP"), nullable=False
|
|
)
|