update setup; update db_model

This commit is contained in:
BryantHe 2023-06-08 21:41:50 +08:00
parent 5b2c5e6c77
commit eb1644736c
2 changed files with 7 additions and 1 deletions

View File

@ -3,10 +3,13 @@ from sqlalchemy.ext.declarative import declarative_base
from datetime import datetime from datetime import datetime
BaseModel = declarative_base() BaseModel = declarative_base()
metadata = BaseModel.metadata
class BaseCrud(BaseModel): class BaseCrud(BaseModel):
__abstract__ = True
# 硬删除 # 硬删除
def delete(self, session, commit=False): def delete(self, session, commit=False):
session.delete(self) session.delete(self)
@ -47,6 +50,8 @@ class BaseCrud(BaseModel):
class InfoCrud(BaseModel): class InfoCrud(BaseModel):
__abstract__ = True
create_time = Column(DateTime(), default=func.now()) create_time = Column(DateTime(), default=func.now())
update_time = Column(DateTime(), default=func.now(), onupdate=func.now()) update_time = Column(DateTime(), default=func.now(), onupdate=func.now())
delete_time = Column(DateTime()) delete_time = Column(DateTime())

View File

@ -60,6 +60,7 @@ setup(
'rocketry': ['rocketry==2.4.0'], 'rocketry': ['rocketry==2.4.0'],
'gutter': ['gutter==0.5.0'], 'gutter': ['gutter==0.5.0'],
'mysql': ['pymysql==1.0.3', 'mysql': ['pymysql==1.0.3',
'sqlalchemy==2.0.15'], 'sqlalchemy==2.0.15',
'sqlacodegen==2.3.0'],
}, },
) )