add attachment model and task order relation to it

This commit is contained in:
dandds
2018-08-24 13:29:19 -04:00
committed by Montana
parent ef2e97713a
commit 54d1e7235b
9 changed files with 145 additions and 10 deletions

View File

@@ -0,0 +1,30 @@
"""add task order association to attachments
Revision ID: 14cd800904bc
Revises: d7db8fd35b41
Create Date: 2018-08-24 11:28:30.894412
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '14cd800904bc'
down_revision = 'd7db8fd35b41'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('task_order', sa.Column('attachment_id', sa.Integer(), nullable=True))
op.create_foreign_key(None, 'task_order', 'attachments', ['attachment_id'], ['id'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'task_order', type_='foreignkey')
op.drop_column('task_order', 'attachment_id')
# ### end Alembic commands ###

View File

@@ -0,0 +1,36 @@
"""add attachment table
Revision ID: d7db8fd35b41
Revises: 0845b2f0f401
Create Date: 2018-08-24 11:27:15.317181
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'd7db8fd35b41'
down_revision = '0845b2f0f401'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('attachments',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('filename', sa.String(), nullable=True),
sa.Column('object_name', sa.String(), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('object_name')
)
op.create_unique_constraint(None, 'task_order', ['number'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'task_order', type_='unique')
op.drop_table('attachments')
# ### end Alembic commands ###