From 40ae34f438db444b0a20ecb06dd6257ca389348c Mon Sep 17 00:00:00 2001 From: dorian451 <112524240+dorian451@users.noreply.github.com> Date: Fri, 3 Nov 2023 16:42:07 -0400 Subject: [PATCH 1/2] revert changes to migration files --- .../migrations/versions/2020-12-04_init.py | 11 ----------- .../versions/2023-04-06_professor_table.py | 19 ++++++++++--------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/src/api/migrations/versions/2020-12-04_init.py b/src/api/migrations/versions/2020-12-04_init.py index 93a61dc61..23c7438d3 100644 --- a/src/api/migrations/versions/2020-12-04_init.py +++ b/src/api/migrations/versions/2020-12-04_init.py @@ -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 ### @@ -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 ### diff --git a/src/api/migrations/versions/2023-04-06_professor_table.py b/src/api/migrations/versions/2023-04-06_professor_table.py index 38c42c97b..8a4c5e72e 100644 --- a/src/api/migrations/versions/2023-04-06_professor_table.py +++ b/src/api/migrations/versions/2023-04-06_professor_table.py @@ -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 ### - From 308a60f8b82f7391b25f4724400a555c577848c0 Mon Sep 17 00:00:00 2001 From: dorian451 <112524240+dorian451@users.noreply.github.com> Date: Fri, 3 Nov 2023 17:02:46 -0400 Subject: [PATCH 2/2] generate migration for professors table with updated columns --- ...make_professor_column_names_match_json_.py | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 src/api/migrations/versions/2023-11-03_make_professor_column_names_match_json_.py diff --git a/src/api/migrations/versions/2023-11-03_make_professor_column_names_match_json_.py b/src/api/migrations/versions/2023-11-03_make_professor_column_names_match_json_.py new file mode 100644 index 000000000..0bf0e60b5 --- /dev/null +++ b/src/api/migrations/versions/2023-11-03_make_professor_column_names_match_json_.py @@ -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 ###