didier/alembic/versions/9e8ce58c0a26_initial_migrat...

53 lines
1.6 KiB
Python
Raw Normal View History

2022-06-17 01:36:47 +02:00
"""Initial migration: Ufora announcements
Revision ID: 9e8ce58c0a26
Revises:
Create Date: 2022-06-17 01:36:02.767151
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '9e8ce58c0a26'
down_revision = None
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('ufora_courses',
sa.Column('course_id', sa.Integer(), nullable=False),
sa.Column('name', sa.Text(), nullable=False),
sa.Column('code', sa.Text(), nullable=False),
sa.Column('year', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('course_id'),
sa.UniqueConstraint('code'),
sa.UniqueConstraint('name')
)
op.create_table('ufora_announcements',
sa.Column('announcement_id', sa.Integer(), nullable=False),
sa.Column('course_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['course_id'], ['ufora_courses.course_id'], ),
sa.PrimaryKeyConstraint('announcement_id')
)
op.create_table('ufora_course_aliases',
sa.Column('alias_id', sa.Integer(), nullable=False),
sa.Column('alias', sa.Text(), nullable=False),
sa.Column('course_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['course_id'], ['ufora_courses.course_id'], ),
sa.PrimaryKeyConstraint('alias_id'),
sa.UniqueConstraint('alias')
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('ufora_course_aliases')
op.drop_table('ufora_announcements')
op.drop_table('ufora_courses')
# ### end Alembic commands ###