#10 Create assignment model
This commit is contained in:
46
backend/migrations/versions/cab0d39ef662_.py
Normal file
46
backend/migrations/versions/cab0d39ef662_.py
Normal file
@@ -0,0 +1,46 @@
|
||||
"""Create assignment model
|
||||
|
||||
Revision ID: cab0d39ef662
|
||||
Revises: 862905f5e34a
|
||||
Create Date: 2023-04-13 18:27:15.748107
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'cab0d39ef662'
|
||||
down_revision = '862905f5e34a'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('assignment',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('name', sa.String(length=128), nullable=True),
|
||||
sa.Column('course_id', sa.Integer(), nullable=True),
|
||||
sa.Column('description', sa.Text(), nullable=True),
|
||||
sa.Column('created_at', sa.DateTime(), nullable=True),
|
||||
sa.ForeignKeyConstraint(['course_id'], ['course.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
with op.batch_alter_table('assignment', schema=None) as batch_op:
|
||||
batch_op.create_index(batch_op.f('ix_assignment_course_id'), ['course_id'], unique=False)
|
||||
batch_op.create_index(batch_op.f('ix_assignment_description'), ['description'], unique=False)
|
||||
batch_op.create_index(batch_op.f('ix_assignment_name'), ['name'], unique=False)
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('assignment', schema=None) as batch_op:
|
||||
batch_op.drop_index(batch_op.f('ix_assignment_name'))
|
||||
batch_op.drop_index(batch_op.f('ix_assignment_description'))
|
||||
batch_op.drop_index(batch_op.f('ix_assignment_course_id'))
|
||||
|
||||
op.drop_table('assignment')
|
||||
# ### end Alembic commands ###
|
||||
Reference in New Issue
Block a user