mirror of
https://github.com/langgenius/dify.git
synced 2026-09-08 02:43:49 +08:00
refactor: migrate TrialApp and AccountTrialAppRecord to TypeBase (#34806)
This commit is contained in:
parent
4d57f04a26
commit
985e71ebf4
@ -898,7 +898,7 @@ class InstalledApp(TypeBase):
|
|||||||
return db.session.scalar(select(Tenant).where(Tenant.id == self.tenant_id))
|
return db.session.scalar(select(Tenant).where(Tenant.id == self.tenant_id))
|
||||||
|
|
||||||
|
|
||||||
class TrialApp(Base):
|
class TrialApp(TypeBase):
|
||||||
__tablename__ = "trial_apps"
|
__tablename__ = "trial_apps"
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
sa.PrimaryKeyConstraint("id", name="trial_app_pkey"),
|
sa.PrimaryKeyConstraint("id", name="trial_app_pkey"),
|
||||||
@ -907,18 +907,26 @@ class TrialApp(Base):
|
|||||||
sa.UniqueConstraint("app_id", name="unique_trail_app_id"),
|
sa.UniqueConstraint("app_id", name="unique_trail_app_id"),
|
||||||
)
|
)
|
||||||
|
|
||||||
id = mapped_column(StringUUID, default=gen_uuidv4_string)
|
id: Mapped[str] = mapped_column(
|
||||||
app_id = mapped_column(StringUUID, nullable=False)
|
StringUUID, insert_default=gen_uuidv4_string, default_factory=gen_uuidv4_string, init=False
|
||||||
tenant_id = mapped_column(StringUUID, nullable=False)
|
)
|
||||||
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
app_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
|
||||||
trial_limit = mapped_column(sa.Integer, nullable=False, default=3)
|
tenant_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
|
||||||
|
created_at: Mapped[datetime] = mapped_column(
|
||||||
|
sa.DateTime,
|
||||||
|
nullable=False,
|
||||||
|
insert_default=func.current_timestamp(),
|
||||||
|
server_default=func.current_timestamp(),
|
||||||
|
init=False,
|
||||||
|
)
|
||||||
|
trial_limit: Mapped[int] = mapped_column(sa.Integer, nullable=False, default=3)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def app(self) -> App | None:
|
def app(self) -> App | None:
|
||||||
return db.session.scalar(select(App).where(App.id == self.app_id))
|
return db.session.scalar(select(App).where(App.id == self.app_id))
|
||||||
|
|
||||||
|
|
||||||
class AccountTrialAppRecord(Base):
|
class AccountTrialAppRecord(TypeBase):
|
||||||
__tablename__ = "account_trial_app_records"
|
__tablename__ = "account_trial_app_records"
|
||||||
__table_args__ = (
|
__table_args__ = (
|
||||||
sa.PrimaryKeyConstraint("id", name="user_trial_app_pkey"),
|
sa.PrimaryKeyConstraint("id", name="user_trial_app_pkey"),
|
||||||
@ -926,11 +934,19 @@ class AccountTrialAppRecord(Base):
|
|||||||
sa.Index("account_trial_app_record_app_id_idx", "app_id"),
|
sa.Index("account_trial_app_record_app_id_idx", "app_id"),
|
||||||
sa.UniqueConstraint("account_id", "app_id", name="unique_account_trial_app_record"),
|
sa.UniqueConstraint("account_id", "app_id", name="unique_account_trial_app_record"),
|
||||||
)
|
)
|
||||||
id = mapped_column(StringUUID, default=gen_uuidv4_string)
|
id: Mapped[str] = mapped_column(
|
||||||
account_id = mapped_column(StringUUID, nullable=False)
|
StringUUID, insert_default=gen_uuidv4_string, default_factory=gen_uuidv4_string, init=False
|
||||||
app_id = mapped_column(StringUUID, nullable=False)
|
)
|
||||||
count = mapped_column(sa.Integer, nullable=False, default=0)
|
account_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
|
||||||
created_at = mapped_column(sa.DateTime, nullable=False, server_default=func.current_timestamp())
|
app_id: Mapped[str] = mapped_column(StringUUID, nullable=False)
|
||||||
|
count: Mapped[int] = mapped_column(sa.Integer, nullable=False, default=0)
|
||||||
|
created_at: Mapped[datetime] = mapped_column(
|
||||||
|
sa.DateTime,
|
||||||
|
nullable=False,
|
||||||
|
insert_default=func.current_timestamp(),
|
||||||
|
server_default=func.current_timestamp(),
|
||||||
|
init=False,
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def app(self) -> App | None:
|
def app(self) -> App | None:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user