Add timestamps to workspace

This commit is contained in:
richard-dds
2018-08-17 11:02:59 -04:00
parent c723c9b326
commit 01778ada05
3 changed files with 39 additions and 1 deletions

7
atst/models/mixins.py Normal file
View File

@@ -0,0 +1,7 @@
from sqlalchemy import Column, func, TIMESTAMP
class TimestampsMixin(object):
time_created = Column(TIMESTAMP(timezone=True), nullable=False, server_default=func.now())
time_updated = Column(TIMESTAMP(timezone=True), nullable=False, server_default=func.now(), onupdate=func.current_timestamp())

View File

@@ -3,9 +3,10 @@ from sqlalchemy.orm import relationship
from atst.models import Base
from atst.models.types import Id
from atst.models.mixins import TimestampsMixin
class Workspace(Base):
class Workspace(Base, TimestampsMixin):
__tablename__ = "workspaces"
id = Id()