47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
"""Create course model
|
|
|
|
Revision ID: 471b4225837e
|
|
Revises: 8e48199f1417
|
|
Create Date: 2023-04-06 14:53:43.061616
|
|
|
|
"""
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '471b4225837e'
|
|
down_revision = '8e48199f1417'
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
op.create_table('course',
|
|
sa.Column('id', sa.Integer(), nullable=False),
|
|
sa.Column('name', sa.String(length=128), nullable=True),
|
|
sa.Column('description', sa.Text(), nullable=True),
|
|
sa.Column('instructor', sa.Integer(), nullable=True),
|
|
sa.Column('created_at', sa.DateTime(), nullable=True),
|
|
sa.ForeignKeyConstraint(['instructor'], ['user.id'], ),
|
|
sa.PrimaryKeyConstraint('id')
|
|
)
|
|
with op.batch_alter_table('course', schema=None) as batch_op:
|
|
batch_op.create_index(batch_op.f('ix_course_description'), ['description'], unique=False)
|
|
batch_op.create_index(batch_op.f('ix_course_instructor'), ['instructor'], unique=False)
|
|
batch_op.create_index(batch_op.f('ix_course_name'), ['name'], unique=False)
|
|
|
|
# ### end Alembic commands ###
|
|
|
|
|
|
def downgrade():
|
|
# ### commands auto generated by Alembic - please adjust! ###
|
|
with op.batch_alter_table('course', schema=None) as batch_op:
|
|
batch_op.drop_index(batch_op.f('ix_course_name'))
|
|
batch_op.drop_index(batch_op.f('ix_course_instructor'))
|
|
batch_op.drop_index(batch_op.f('ix_course_description'))
|
|
|
|
op.drop_table('course')
|
|
# ### end Alembic commands ###
|