mirror of
https://github.com/fastapi-practices/fastapi-best-architecture.git
synced 2026-09-21 21:15:13 +00:00
Update the primary database to postgresql (#829)
* Update the primary database to postgresql * Delete the prints * Fix lint * Update models in code generation * Delete print * Fix the salt column type
This commit is contained in:
@@ -2,9 +2,9 @@ from __future__ import annotations
|
||||
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from sqlalchemy import BigInteger, ForeignKey, String
|
||||
import sqlalchemy as sa
|
||||
|
||||
from sqlalchemy.dialects.mysql import LONGTEXT
|
||||
from sqlalchemy.dialects.postgresql import TEXT
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from backend.common.model import DataClassBase, id_key
|
||||
@@ -19,14 +19,12 @@ class GenColumn(DataClassBase):
|
||||
__tablename__ = 'gen_column'
|
||||
|
||||
id: Mapped[id_key] = mapped_column(init=False)
|
||||
name: Mapped[str] = mapped_column(String(50), comment='列名称')
|
||||
comment: Mapped[str | None] = mapped_column(String(255), default=None, comment='列描述')
|
||||
type: Mapped[str] = mapped_column(String(20), default='String', comment='SQLA 模型列类型')
|
||||
pd_type: Mapped[str] = mapped_column(String(20), default='str', comment='列类型对应的 pydantic 类型')
|
||||
name: Mapped[str] = mapped_column(sa.String(50), comment='列名称')
|
||||
comment: Mapped[str | None] = mapped_column(sa.String(255), default=None, comment='列描述')
|
||||
type: Mapped[str] = mapped_column(sa.String(20), default='String', comment='SQLA 模型列类型')
|
||||
pd_type: Mapped[str] = mapped_column(sa.String(20), default='str', comment='列类型对应的 pydantic 类型')
|
||||
default: Mapped[str | None] = mapped_column(
|
||||
LONGTEXT().with_variant(TEXT, 'postgresql'),
|
||||
default=None,
|
||||
comment='列默认值',
|
||||
sa.TEXT().with_variant(LONGTEXT, 'mysql'), default=None, comment='列默认值'
|
||||
)
|
||||
sort: Mapped[int | None] = mapped_column(default=1, comment='列排序')
|
||||
length: Mapped[int] = mapped_column(default=0, comment='列长度')
|
||||
@@ -35,9 +33,6 @@ class GenColumn(DataClassBase):
|
||||
|
||||
# 代码生成业务模型列一对多
|
||||
gen_business_id: Mapped[int] = mapped_column(
|
||||
BigInteger,
|
||||
ForeignKey('gen_business.id', ondelete='CASCADE'),
|
||||
default=0,
|
||||
comment='代码生成业务ID',
|
||||
sa.BigInteger, sa.ForeignKey('gen_business.id', ondelete='CASCADE'), default=0, comment='代码生成业务ID'
|
||||
)
|
||||
gen_business: Mapped[GenBusiness | None] = relationship(init=False, back_populates='gen_column')
|
||||
|
||||
Reference in New Issue
Block a user