mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-09 17:19:49 -04:00
notify-api-141 add agreement to models.py
This commit is contained in:
@@ -1977,3 +1977,33 @@ class WebauthnCredential(db.Model):
|
|||||||
'created_at': self.created_at.strftime(DATETIME_FORMAT),
|
'created_at': self.created_at.strftime(DATETIME_FORMAT),
|
||||||
'updated_at': get_dt_string_or_none(self.updated_at),
|
'updated_at': get_dt_string_or_none(self.updated_at),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
class Agreement(db.Model):
|
||||||
|
__tablename__ = "agreements"
|
||||||
|
id = db.Column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4, unique=False)
|
||||||
|
type = db.Column(db.String(3), nullable=False, unique=True, index=True)
|
||||||
|
partner_name = db.Column(db.String(255), nullable=False, unique=True, index=True)
|
||||||
|
status = db.Column(db.String(255), nullable=False, unique=True, index=True)
|
||||||
|
start_time = db.Column(db.DateTime, nullable=True)
|
||||||
|
end_time = db.Column(db.DateTime, nullable=True)
|
||||||
|
url = db.Column(db.String(255), nullable=False, unique=True, index=True)
|
||||||
|
budget_amount = db.Column(db.Float, nullable=True)
|
||||||
|
organization_id = db.Column(
|
||||||
|
UUID(as_uuid=True),
|
||||||
|
db.ForeignKey('organization.id'),
|
||||||
|
nullable=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
def serialize(self):
|
||||||
|
return {
|
||||||
|
"id": str(self.id),
|
||||||
|
"type": self.type,
|
||||||
|
"partner_name": self.partner_name,
|
||||||
|
"status": self.status,
|
||||||
|
"start_time": self.start_time.strftime(DATETIME_FORMAT),
|
||||||
|
"end_time": self.end_time.strftime(DATETIME_FORMAT),
|
||||||
|
"budget_amount": self.budget_amount,
|
||||||
|
"organization_id": self.organization_id
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
37
migrations/versions/0398_agreements_table.py
Normal file
37
migrations/versions/0398_agreements_table.py
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: 0010_events_table
|
||||||
|
Revises: 0009_created_by_for_jobs
|
||||||
|
Create Date: 2016-04-26 13:08:42.892813
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = '0398_agreements_table'
|
||||||
|
down_revision = '0397_rename_organisation_2'
|
||||||
|
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import postgresql
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.create_table('agreements',
|
||||||
|
sa.Column('id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.Column('type', sa.String(length=3), nullable=False),
|
||||||
|
sa.Column('partner_name', sa.String(length=255), nullable=False),
|
||||||
|
sa.Column('status', sa.String(length=255), nullable=False),
|
||||||
|
sa.Column('start_time', sa.DateTime(), nullable=False),
|
||||||
|
sa.Column('end_time', sa.DateTime(), nullable=False),
|
||||||
|
sa.Column('url', sa.String(length=255), nullable=False),
|
||||||
|
sa.Column('budget_amount', sa.Float(), nullable=False),
|
||||||
|
sa.Column('organization_id', postgresql.UUID(as_uuid=True), nullable=False),
|
||||||
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
)
|
||||||
|
### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
### commands auto generated by Alembic - please adjust! ###
|
||||||
|
op.drop_table('agreements')
|
||||||
|
### end Alembic commands ###
|
||||||
Reference in New Issue
Block a user