Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add proper professor table migration #841

Merged
merged 2 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions src/api/migrations/versions/2020-12-04_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,6 @@ def upgrade():
sa.ForeignKeyConstraint(['user_id'], ['user_account.user_id'], ),
sa.PrimaryKeyConstraint('user_id', 'semester', 'course_name', 'crn')
)
# op.create_table('professor',
# sa.Column('email', sa.VARCHAR(length=255), nullable=False),
# sa.Column('first_name', sa.VARCHAR(length=255), nullable=True),
# sa.Column('phone_number', sa.VARCHAR(length=255), nullable=True),
# sa.Column('department', sa.VARCHAR(length=255), nullable=True),
# sa.Column('Title', sa.VARCHAR(length=255), nullable=True),
# sa.Column('Portfolio', sa.VARCHAR(length=255), nullable=True),
# sa.Column('Portfolio_page', sa.VARCHAR(length=255), nullable=True),
# sa.PrimaryKeyConstraint('email')
# )
# ### end Alembic commands ###


Expand All @@ -142,5 +132,4 @@ def downgrade():
op.drop_table('course_corequisite')
op.drop_table('course')
op.drop_table('admin_settings')
# op.drop_table('professor')
# ### end Alembic commands ###
19 changes: 10 additions & 9 deletions src/api/migrations/versions/2023-04-06_professor_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,25 @@
depends_on = None


#BUILDS THE TABLE
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
#CHANGE COLUMNS
op.create_table('professor',
sa.Column('email', sa.VARCHAR(length=255), nullable=False),
sa.Column('name', sa.VARCHAR(length=255), nullable=True),
sa.Column('title', sa.VARCHAR(length=255), nullable=True),
sa.Column('first_name', sa.VARCHAR(length=255), nullable=True),
sa.Column('last_name', sa.VARCHAR(length=255), nullable=True),
sa.Column('phone_number', sa.VARCHAR(length=255), nullable=True),
sa.Column('department', sa.VARCHAR(length=255), nullable=True),
sa.Column('portfolio_page', sa.VARCHAR(length=255), nullable=True),
sa.Column('profile_page', sa.VARCHAR(length=255), nullable=True),
sa.Column('office_room', sa.VARCHAR(length=255), nullable=True),
sa.Column('classes', sa.VARCHAR(length=255), nullable=True),
sa.Column('office_hours_time', sa.VARCHAR(length=255), nullable=True),
sa.Column('rcs', sa.VARCHAR(length=255), nullable=True),
sa.PrimaryKeyConstraint('email')
)
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('professor')
# def downgrade():
# # ### commands auto generated by Alembic - please adjust! ###
# op.drop_table('professor')
# ### end Alembic commands ###

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
"""make professor column names match json file

Revision ID: c0289fddf6dd
Revises: 95cb2a021aa9
Create Date: 2023-11-03 20:51:02.027398

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'c0289fddf6dd'
down_revision = '95cb2a021aa9'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('professor', sa.Column('Department', sa.VARCHAR(length=255), nullable=True))
op.add_column('professor', sa.Column('Email', sa.VARCHAR(length=255), nullable=False))
op.add_column('professor', sa.Column('Name', sa.VARCHAR(length=255), nullable=True))
op.add_column('professor', sa.Column('Phone_number', sa.VARCHAR(length=255), nullable=True))
op.add_column('professor', sa.Column('Portfolio_page', sa.VARCHAR(length=255), nullable=True))
op.add_column('professor', sa.Column('Profile_page', sa.VARCHAR(length=255), nullable=True))
op.add_column('professor', sa.Column('Title', sa.VARCHAR(length=255), nullable=True))
op.drop_column('professor', 'first_name')
op.drop_column('professor', 'rcs')
op.drop_column('professor', 'last_name')
op.drop_column('professor', 'office_hours_time')
op.drop_column('professor', 'department')
op.drop_column('professor', 'email')
op.drop_column('professor', 'office_room')
op.drop_column('professor', 'phone_number')
op.drop_column('professor', 'classes')
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('professor', sa.Column('classes', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.add_column('professor', sa.Column('phone_number', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.add_column('professor', sa.Column('office_room', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.add_column('professor', sa.Column('email', sa.VARCHAR(length=255), autoincrement=False, nullable=False))
op.add_column('professor', sa.Column('department', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.add_column('professor', sa.Column('office_hours_time', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.add_column('professor', sa.Column('last_name', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.add_column('professor', sa.Column('rcs', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.add_column('professor', sa.Column('first_name', sa.VARCHAR(length=255), autoincrement=False, nullable=True))
op.drop_column('professor', 'Title')
op.drop_column('professor', 'Profile_page')
op.drop_column('professor', 'Portfolio_page')
op.drop_column('professor', 'Phone_number')
op.drop_column('professor', 'Name')
op.drop_column('professor', 'Email')
op.drop_column('professor', 'Department')
# ### end Alembic commands ###
Loading