#70 Add content model

This commit is contained in:
2023-04-14 16:47:27 -04:00
parent b03c50445f
commit 80ccc17eef
2 changed files with 71 additions and 2 deletions

View File

@@ -0,0 +1,46 @@
"""Create content model
Revision ID: c62aec1c6b91
Revises: 1e88e783d238
Create Date: 2023-04-14 16:46:43.513842
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'c62aec1c6b91'
down_revision = '1e88e783d238'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('content',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=128), nullable=True),
sa.Column('body', sa.Text(), nullable=True),
sa.Column('course_id', sa.Integer(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=True),
sa.ForeignKeyConstraint(['course_id'], ['course.id'], ),
sa.PrimaryKeyConstraint('id')
)
with op.batch_alter_table('content', schema=None) as batch_op:
batch_op.create_index(batch_op.f('ix_content_body'), ['body'], unique=False)
batch_op.create_index(batch_op.f('ix_content_course_id'), ['course_id'], unique=False)
batch_op.create_index(batch_op.f('ix_content_name'), ['name'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('content', schema=None) as batch_op:
batch_op.drop_index(batch_op.f('ix_content_name'))
batch_op.drop_index(batch_op.f('ix_content_course_id'))
batch_op.drop_index(batch_op.f('ix_content_body'))
op.drop_table('content')
# ### end Alembic commands ###