2. Fixed the issue of new users not being bound to the default resource group after logging in
31 lines
1.3 KiB
Python
31 lines
1.3 KiB
Python
from sqlalchemy import Integer, String, Text, DateTime, false
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.orm import Mapped, mapped_column
|
|
from services.common.models.base import Base
|
|
from datetime import datetime
|
|
|
|
|
|
class UserApiKey(Base):
|
|
__tablename__ = "user_apikey"
|
|
|
|
id: Mapped[str] = mapped_column(String(36), primary_key=True, autoincrement=False, comment="Primary key")
|
|
user_id: Mapped[str] = mapped_column(String(36), nullable=False, comment="User ID")
|
|
name: Mapped[str] = mapped_column(String(255), nullable=False, comment="Name")
|
|
description: Mapped[str] = mapped_column(Text, nullable=True, comment="Description")
|
|
apikey: Mapped[str] = mapped_column(String(255), unique=True, nullable=False, comment="API key")
|
|
expire_at: Mapped[datetime] = mapped_column(DateTime, nullable=True, comment="Expiration time")
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime,
|
|
nullable=True,
|
|
server_default=func.current_timestamp(),
|
|
comment="Creation timestamp",
|
|
)
|
|
updated_at: Mapped[datetime] = mapped_column(
|
|
DateTime,
|
|
nullable=True,
|
|
server_default=func.current_timestamp(),
|
|
server_onupdate=func.current_timestamp(),
|
|
comment="Last update timestamp",
|
|
)
|
|
is_deleted: Mapped[int] = mapped_column(Integer,nullable=False,default=0,comment="Already be Deleted")
|