Add Request.internal_comments
Using a one to one relationship to avoid the migration hell that we're temporarily stuck in.
This commit is contained in:
parent
31d6bd3663
commit
100048afdf
@ -0,0 +1,36 @@
|
||||
"""add request.internal_comments
|
||||
|
||||
Revision ID: 2572be7fb7fc
|
||||
Revises: dea6b8e09d63
|
||||
Create Date: 2018-09-11 15:28:27.252248
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2572be7fb7fc'
|
||||
down_revision = 'dea6b8e09d63'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('request_internal_comments',
|
||||
sa.Column('id', sa.BigInteger(), nullable=False),
|
||||
sa.Column('text', sa.String(), nullable=True),
|
||||
sa.Column('user_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||
sa.Column('request_id', postgresql.UUID(as_uuid=True), nullable=True),
|
||||
sa.ForeignKeyConstraint(['request_id'], ['requests.id'], ondelete='CASCADE'),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('request_internal_comments')
|
||||
# ### end Alembic commands ###
|
@ -16,3 +16,4 @@ from .environment import Environment
|
||||
from .attachment import Attachment
|
||||
from .request_revision import RequestRevision
|
||||
from .request_review import RequestReview
|
||||
from .request_internal_comment import RequestInternalComment
|
||||
|
@ -46,6 +46,8 @@ class Request(Base):
|
||||
"RequestRevision", back_populates="request", order_by="RequestRevision.sequence"
|
||||
)
|
||||
|
||||
internal_comments = relationship("RequestInternalComment", uselist=False)
|
||||
|
||||
@property
|
||||
def latest_revision(self):
|
||||
if self.revisions:
|
||||
|
16
atst/models/request_internal_comment.py
Normal file
16
atst/models/request_internal_comment.py
Normal file
@ -0,0 +1,16 @@
|
||||
from sqlalchemy import Column, BigInteger, String, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
|
||||
from atst.models import Base
|
||||
|
||||
|
||||
class RequestInternalComment(Base):
|
||||
__tablename__ = "request_internal_comments"
|
||||
|
||||
id = Column(BigInteger, primary_key=True)
|
||||
text = Column(String())
|
||||
|
||||
user_id = Column(ForeignKey("users.id"), nullable=False)
|
||||
user = relationship("User")
|
||||
|
||||
request_id = Column(ForeignKey("requests.id", ondelete="CASCADE"))
|
Loading…
x
Reference in New Issue
Block a user