diff --git a/migrations/script.py.mako b/migrations/script.py.mako index 2c0156303..4f44da1dc 100644 --- a/migrations/script.py.mako +++ b/migrations/script.py.mako @@ -17,8 +17,8 @@ depends_on = ${repr(depends_on)} def upgrade(): - ${upgrades if upgrades else "pass"} + ${upgrades if upgrades else "pass"} def downgrade(): - ${downgrades if downgrades else "pass"} + ${downgrades if downgrades else "pass"} diff --git a/migrations/versions/2022_05_12_03_08_32_4a1f7859151b_update_db_to_match_models_at_fork_time.py b/migrations/versions/2022_05_12_03_08_32_4a1f7859151b_update_db_to_match_models_at_fork_time.py index 2ec5a8820..604082d7a 100644 --- a/migrations/versions/2022_05_12_03_08_32_4a1f7859151b_update_db_to_match_models_at_fork_time.py +++ b/migrations/versions/2022_05_12_03_08_32_4a1f7859151b_update_db_to_match_models_at_fork_time.py @@ -17,22 +17,22 @@ depends_on = None def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('submissions', sa.Column('bump_utc', sa.Integer(), server_default=sa.schema.FetchedValue(), nullable=True)) - op.create_foreign_key('comments_app_id_fkey', 'comments', 'oauth_apps', ['app_id'], ['id']) - op.create_foreign_key('commentvotes_app_id_fkey', 'commentvotes', 'oauth_apps', ['app_id'], ['id']) - op.create_foreign_key('modactions_user_id_fkey', 'modactions', 'users', ['user_id'], ['id']) - op.create_foreign_key('submissions_app_id_fkey', 'submissions', 'oauth_apps', ['app_id'], ['id']) - op.create_foreign_key('votes_app_id_fkey', 'votes', 'oauth_apps', ['app_id'], ['id']) - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('submissions', sa.Column('bump_utc', sa.Integer(), server_default=sa.schema.FetchedValue(), nullable=True)) + op.create_foreign_key('comments_app_id_fkey', 'comments', 'oauth_apps', ['app_id'], ['id']) + op.create_foreign_key('commentvotes_app_id_fkey', 'commentvotes', 'oauth_apps', ['app_id'], ['id']) + op.create_foreign_key('modactions_user_id_fkey', 'modactions', 'users', ['user_id'], ['id']) + op.create_foreign_key('submissions_app_id_fkey', 'submissions', 'oauth_apps', ['app_id'], ['id']) + op.create_foreign_key('votes_app_id_fkey', 'votes', 'oauth_apps', ['app_id'], ['id']) + # ### end Alembic commands ### def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint('votes_app_id_fkey', 'votes', type_='foreignkey') - op.drop_constraint('submissions_app_id_fkey', 'submissions', type_='foreignkey') - op.drop_constraint('modactions_user_id_fkey', 'modactions', type_='foreignkey') - op.drop_constraint('commentvotes_app_id_fkey', 'commentvotes', type_='foreignkey') - op.drop_constraint('comments_app_id_fkey', 'comments', type_='foreignkey') - op.drop_column('submissions', 'bump_utc') - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint('votes_app_id_fkey', 'votes', type_='foreignkey') + op.drop_constraint('submissions_app_id_fkey', 'submissions', type_='foreignkey') + op.drop_constraint('modactions_user_id_fkey', 'modactions', type_='foreignkey') + op.drop_constraint('commentvotes_app_id_fkey', 'commentvotes', type_='foreignkey') + op.drop_constraint('comments_app_id_fkey', 'comments', type_='foreignkey') + op.drop_column('submissions', 'bump_utc') + # ### end Alembic commands ### diff --git a/migrations/versions/2022_05_16_19_42_28_16d6335dd9a3_add_usernotes_constraints.py b/migrations/versions/2022_05_16_19_42_28_16d6335dd9a3_add_usernotes_constraints.py index 1fba05225..46ccdf764 100644 --- a/migrations/versions/2022_05_16_19_42_28_16d6335dd9a3_add_usernotes_constraints.py +++ b/migrations/versions/2022_05_16_19_42_28_16d6335dd9a3_add_usernotes_constraints.py @@ -17,30 +17,30 @@ depends_on = None def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('usernotes', 'note', - existing_type=sa.VARCHAR(length=10000), - nullable=False) - op.alter_column('usernotes', 'tag', - existing_type=sa.VARCHAR(length=10), - nullable=False) - op.create_foreign_key('usernotes_author_id_fkey', 'usernotes', 'users', ['author_id'], ['id']) - op.create_foreign_key('usernotes_reference_comment_fkey', 'usernotes', 'comments', ['reference_comment'], ['id'], ondelete='SET NULL') - op.create_foreign_key('usernotes_reference_post_fkey', 'usernotes', 'submissions', ['reference_post'], ['id'], ondelete='SET NULL') - op.create_foreign_key('usernotes_reference_user_fkey', 'usernotes', 'users', ['reference_user'], ['id'], ondelete='CASCADE') - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('usernotes', 'note', + existing_type=sa.VARCHAR(length=10000), + nullable=False) + op.alter_column('usernotes', 'tag', + existing_type=sa.VARCHAR(length=10), + nullable=False) + op.create_foreign_key('usernotes_author_id_fkey', 'usernotes', 'users', ['author_id'], ['id']) + op.create_foreign_key('usernotes_reference_comment_fkey', 'usernotes', 'comments', ['reference_comment'], ['id'], ondelete='SET NULL') + op.create_foreign_key('usernotes_reference_post_fkey', 'usernotes', 'submissions', ['reference_post'], ['id'], ondelete='SET NULL') + op.create_foreign_key('usernotes_reference_user_fkey', 'usernotes', 'users', ['reference_user'], ['id'], ondelete='CASCADE') + # ### end Alembic commands ### def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint('usernotes_reference_user_fkey', 'usernotes', type_='foreignkey') - op.drop_constraint('usernotes_reference_post_fkey', 'usernotes', type_='foreignkey') - op.drop_constraint('usernotes_reference_comment_fkey', 'usernotes', type_='foreignkey') - op.drop_constraint('usernotes_author_id_fkey', 'usernotes', type_='foreignkey') - op.alter_column('usernotes', 'tag', - existing_type=sa.VARCHAR(length=10), - nullable=True) - op.alter_column('usernotes', 'note', - existing_type=sa.VARCHAR(length=10000), - nullable=True) - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint('usernotes_reference_user_fkey', 'usernotes', type_='foreignkey') + op.drop_constraint('usernotes_reference_post_fkey', 'usernotes', type_='foreignkey') + op.drop_constraint('usernotes_reference_comment_fkey', 'usernotes', type_='foreignkey') + op.drop_constraint('usernotes_author_id_fkey', 'usernotes', type_='foreignkey') + op.alter_column('usernotes', 'tag', + existing_type=sa.VARCHAR(length=10), + nullable=True) + op.alter_column('usernotes', 'note', + existing_type=sa.VARCHAR(length=10000), + nullable=True) + # ### end Alembic commands ### diff --git a/migrations/versions/2022_09_04_21_49_42_c217c608d86c_remove_treasure_amount_from_comments.py b/migrations/versions/2022_09_04_21_49_42_c217c608d86c_remove_treasure_amount_from_comments.py index 7e419750f..61dfcdeaa 100644 --- a/migrations/versions/2022_09_04_21_49_42_c217c608d86c_remove_treasure_amount_from_comments.py +++ b/migrations/versions/2022_09_04_21_49_42_c217c608d86c_remove_treasure_amount_from_comments.py @@ -17,12 +17,12 @@ depends_on = None def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('comments', 'treasure_amount') - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('comments', 'treasure_amount') + # ### end Alembic commands ### def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('comments', sa.Column('treasure_amount', sa.VARCHAR(length=10), autoincrement=False, nullable=True)) - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('comments', sa.Column('treasure_amount', sa.VARCHAR(length=10), autoincrement=False, nullable=True)) + # ### end Alembic commands ### diff --git a/migrations/versions/2022_09_05_08_41_14_44a40481ca2b_remove_games_from_comments.py b/migrations/versions/2022_09_05_08_41_14_44a40481ca2b_remove_games_from_comments.py index 9a652dd74..9deac1af8 100644 --- a/migrations/versions/2022_09_05_08_41_14_44a40481ca2b_remove_games_from_comments.py +++ b/migrations/versions/2022_09_05_08_41_14_44a40481ca2b_remove_games_from_comments.py @@ -17,16 +17,16 @@ depends_on = None def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('comments', 'slots_result') - op.drop_column('comments', 'blackjack_result') - op.drop_column('comments', 'wordle_result') - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('comments', 'slots_result') + op.drop_column('comments', 'blackjack_result') + op.drop_column('comments', 'wordle_result') + # ### end Alembic commands ### def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('comments', sa.Column('wordle_result', sa.VARCHAR(length=115), autoincrement=False, nullable=True)) - op.add_column('comments', sa.Column('blackjack_result', sa.VARCHAR(length=860), autoincrement=False, nullable=True)) - op.add_column('comments', sa.Column('slots_result', sa.VARCHAR(length=32), autoincrement=False, nullable=True)) - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('comments', sa.Column('wordle_result', sa.VARCHAR(length=115), autoincrement=False, nullable=True)) + op.add_column('comments', sa.Column('blackjack_result', sa.VARCHAR(length=860), autoincrement=False, nullable=True)) + op.add_column('comments', sa.Column('slots_result', sa.VARCHAR(length=32), autoincrement=False, nullable=True)) + # ### end Alembic commands ### diff --git a/migrations/versions/2022_11_06_22_06_07_61c6f838c5c6_remove_signatures_feature.py b/migrations/versions/2022_11_06_22_06_07_61c6f838c5c6_remove_signatures_feature.py index b7fa89505..3a5a1bd83 100644 --- a/migrations/versions/2022_11_06_22_06_07_61c6f838c5c6_remove_signatures_feature.py +++ b/migrations/versions/2022_11_06_22_06_07_61c6f838c5c6_remove_signatures_feature.py @@ -17,16 +17,16 @@ depends_on = None def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('users', 'sigs_disabled') - op.drop_column('users', 'sig_html') - op.drop_column('users', 'sig') - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('users', 'sigs_disabled') + op.drop_column('users', 'sig_html') + op.drop_column('users', 'sig') + # ### end Alembic commands ### def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('users', sa.Column('sig', sa.VARCHAR(length=200), autoincrement=False, nullable=True)) - op.add_column('users', sa.Column('sig_html', sa.VARCHAR(length=1000), autoincrement=False, nullable=True)) - op.add_column('users', sa.Column('sigs_disabled', sa.BOOLEAN(), autoincrement=False, nullable=True)) - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('users', sa.Column('sig', sa.VARCHAR(length=200), autoincrement=False, nullable=True)) + op.add_column('users', sa.Column('sig_html', sa.VARCHAR(length=1000), autoincrement=False, nullable=True)) + op.add_column('users', sa.Column('sigs_disabled', sa.BOOLEAN(), autoincrement=False, nullable=True)) + # ### end Alembic commands ### diff --git a/migrations/versions/2022_11_07_08_04_52_0d4c7cf3da6d_remove_many_user_award_tracking_columns.py b/migrations/versions/2022_11_07_08_04_52_0d4c7cf3da6d_remove_many_user_award_tracking_columns.py index 88e862584..9e2f44d8a 100644 --- a/migrations/versions/2022_11_07_08_04_52_0d4c7cf3da6d_remove_many_user_award_tracking_columns.py +++ b/migrations/versions/2022_11_07_08_04_52_0d4c7cf3da6d_remove_many_user_award_tracking_columns.py @@ -17,34 +17,34 @@ depends_on = None def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('users', 'alt') - op.drop_column('users', 'unblockable') - op.drop_column('users', 'deflector') - op.drop_column('users', 'bird') - op.drop_column('users', 'rehab') - op.drop_column('users', 'fish') - op.drop_column('users', 'mute') - op.drop_column('users', 'eye') - op.drop_column('users', 'longpost') - op.drop_column('users', 'marseyawarded') - op.drop_column('users', 'progressivestack') - op.drop_column('users', 'unmutable') - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('users', 'alt') + op.drop_column('users', 'unblockable') + op.drop_column('users', 'deflector') + op.drop_column('users', 'bird') + op.drop_column('users', 'rehab') + op.drop_column('users', 'fish') + op.drop_column('users', 'mute') + op.drop_column('users', 'eye') + op.drop_column('users', 'longpost') + op.drop_column('users', 'marseyawarded') + op.drop_column('users', 'progressivestack') + op.drop_column('users', 'unmutable') + # ### end Alembic commands ### def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('users', sa.Column('unmutable', sa.BOOLEAN(), autoincrement=False, nullable=True)) - op.add_column('users', sa.Column('progressivestack', sa.INTEGER(), autoincrement=False, nullable=True)) - op.add_column('users', sa.Column('marseyawarded', sa.INTEGER(), autoincrement=False, nullable=True)) - op.add_column('users', sa.Column('longpost', sa.INTEGER(), autoincrement=False, nullable=True)) - op.add_column('users', sa.Column('eye', sa.BOOLEAN(), autoincrement=False, nullable=True)) - op.add_column('users', sa.Column('mute', sa.BOOLEAN(), autoincrement=False, nullable=True)) - op.add_column('users', sa.Column('fish', sa.BOOLEAN(), autoincrement=False, nullable=True)) - op.add_column('users', sa.Column('rehab', sa.INTEGER(), autoincrement=False, nullable=True)) - op.add_column('users', sa.Column('bird', sa.INTEGER(), autoincrement=False, nullable=True)) - op.add_column('users', sa.Column('deflector', sa.INTEGER(), autoincrement=False, nullable=True)) - op.add_column('users', sa.Column('unblockable', sa.BOOLEAN(), autoincrement=False, nullable=True)) - op.add_column('users', sa.Column('alt', sa.BOOLEAN(), autoincrement=False, nullable=True)) - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('users', sa.Column('unmutable', sa.BOOLEAN(), autoincrement=False, nullable=True)) + op.add_column('users', sa.Column('progressivestack', sa.INTEGER(), autoincrement=False, nullable=True)) + op.add_column('users', sa.Column('marseyawarded', sa.INTEGER(), autoincrement=False, nullable=True)) + op.add_column('users', sa.Column('longpost', sa.INTEGER(), autoincrement=False, nullable=True)) + op.add_column('users', sa.Column('eye', sa.BOOLEAN(), autoincrement=False, nullable=True)) + op.add_column('users', sa.Column('mute', sa.BOOLEAN(), autoincrement=False, nullable=True)) + op.add_column('users', sa.Column('fish', sa.BOOLEAN(), autoincrement=False, nullable=True)) + op.add_column('users', sa.Column('rehab', sa.INTEGER(), autoincrement=False, nullable=True)) + op.add_column('users', sa.Column('bird', sa.INTEGER(), autoincrement=False, nullable=True)) + op.add_column('users', sa.Column('deflector', sa.INTEGER(), autoincrement=False, nullable=True)) + op.add_column('users', sa.Column('unblockable', sa.BOOLEAN(), autoincrement=False, nullable=True)) + op.add_column('users', sa.Column('alt', sa.BOOLEAN(), autoincrement=False, nullable=True)) + # ### end Alembic commands ### diff --git a/migrations/versions/2022_11_14_11_24_55_d7a4a6723411_add_per_user_field_for_the_last_usage_.py b/migrations/versions/2022_11_14_11_24_55_d7a4a6723411_add_per_user_field_for_the_last_usage_.py index 3d33ae891..2e0ba230a 100644 --- a/migrations/versions/2022_11_14_11_24_55_d7a4a6723411_add_per_user_field_for_the_last_usage_.py +++ b/migrations/versions/2022_11_14_11_24_55_d7a4a6723411_add_per_user_field_for_the_last_usage_.py @@ -17,12 +17,12 @@ depends_on = None def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('users', sa.Column('volunteer_last_started_utc', sa.DateTime(), nullable=True)) - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('users', sa.Column('volunteer_last_started_utc', sa.DateTime(), nullable=True)) + # ### end Alembic commands ### def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('users', 'volunteer_last_started_utc') - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('users', 'volunteer_last_started_utc') + # ### end Alembic commands ### diff --git a/migrations/versions/2022_11_19_10_21_36_65ce80ffc30e_add_volunteer_janitor_tracking.py b/migrations/versions/2022_11_19_10_21_36_65ce80ffc30e_add_volunteer_janitor_tracking.py index 950243e91..02e1ebd9e 100644 --- a/migrations/versions/2022_11_19_10_21_36_65ce80ffc30e_add_volunteer_janitor_tracking.py +++ b/migrations/versions/2022_11_19_10_21_36_65ce80ffc30e_add_volunteer_janitor_tracking.py @@ -17,23 +17,23 @@ depends_on = None def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('volunteer_janitor', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('user_id', sa.Integer(), nullable=False), - sa.Column('comment_id', sa.Integer(), nullable=False), - sa.Column('edited_utc', sa.DateTime(), nullable=False), - sa.Column('result', sa.Enum('Pending', 'TopQuality', 'Good', 'Neutral', 'Bad', 'Warning', 'Ban', name='volunteerjanitorresult'), nullable=False), - sa.ForeignKeyConstraint(['comment_id'], ['comments.id'], ), - sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_index('volunteer_comment_index', 'volunteer_janitor', ['user_id', 'comment_id'], unique=False) - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('volunteer_janitor', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('user_id', sa.Integer(), nullable=False), + sa.Column('comment_id', sa.Integer(), nullable=False), + sa.Column('edited_utc', sa.DateTime(), nullable=False), + sa.Column('result', sa.Enum('Pending', 'TopQuality', 'Good', 'Neutral', 'Bad', 'Warning', 'Ban', name='volunteerjanitorresult'), nullable=False), + sa.ForeignKeyConstraint(['comment_id'], ['comments.id'], ), + sa.ForeignKeyConstraint(['user_id'], ['users.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_index('volunteer_comment_index', 'volunteer_janitor', ['user_id', 'comment_id'], unique=False) + # ### end Alembic commands ### def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index('volunteer_comment_index', table_name='volunteer_janitor') - op.drop_table('volunteer_janitor') - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index('volunteer_comment_index', table_name='volunteer_janitor') + op.drop_table('volunteer_janitor') + # ### end Alembic commands ### diff --git a/migrations/versions/2022_11_20_10_10_48_e2cd2818a196_changes_to_volunteer_janitor_behavior.py b/migrations/versions/2022_11_20_10_10_48_e2cd2818a196_changes_to_volunteer_janitor_behavior.py index 64d46fa04..87152dcc2 100644 --- a/migrations/versions/2022_11_20_10_10_48_e2cd2818a196_changes_to_volunteer_janitor_behavior.py +++ b/migrations/versions/2022_11_20_10_10_48_e2cd2818a196_changes_to_volunteer_janitor_behavior.py @@ -17,14 +17,14 @@ depends_on = None def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('volunteer_janitor', sa.Column('recorded_utc', sa.DateTime(), nullable=False)) - op.drop_column('volunteer_janitor', 'edited_utc') - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('volunteer_janitor', sa.Column('recorded_utc', sa.DateTime(), nullable=False)) + op.drop_column('volunteer_janitor', 'edited_utc') + # ### end Alembic commands ### def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('volunteer_janitor', sa.Column('edited_utc', postgresql.TIMESTAMP(), autoincrement=False, nullable=False)) - op.drop_column('volunteer_janitor', 'recorded_utc') - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('volunteer_janitor', sa.Column('edited_utc', postgresql.TIMESTAMP(), autoincrement=False, nullable=False)) + op.drop_column('volunteer_janitor', 'recorded_utc') + # ### end Alembic commands ### diff --git a/migrations/versions/2022_11_21_17_52_32_b23ec080ecb7_remove_discord_user_properties.py b/migrations/versions/2022_11_21_17_52_32_b23ec080ecb7_remove_discord_user_properties.py index 51fc6eff6..b1a002dee 100644 --- a/migrations/versions/2022_11_21_17_52_32_b23ec080ecb7_remove_discord_user_properties.py +++ b/migrations/versions/2022_11_21_17_52_32_b23ec080ecb7_remove_discord_user_properties.py @@ -17,16 +17,16 @@ depends_on = None def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index('discord_id_idx', table_name='users') - op.drop_constraint('one_discord_account', 'users', type_='unique') - op.drop_column('users', 'discord_id') - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.drop_index('discord_id_idx', table_name='users') + op.drop_constraint('one_discord_account', 'users', type_='unique') + op.drop_column('users', 'discord_id') + # ### end Alembic commands ### def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('users', sa.Column('discord_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True)) - op.create_unique_constraint('one_discord_account', 'users', ['discord_id']) - op.create_index('discord_id_idx', 'users', ['discord_id'], unique=False) - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('users', sa.Column('discord_id', sa.VARCHAR(length=64), autoincrement=False, nullable=True)) + op.create_unique_constraint('one_discord_account', 'users', ['discord_id']) + op.create_index('discord_id_idx', 'users', ['discord_id'], unique=False) + # ### end Alembic commands ### diff --git a/migrations/versions/2023_01_03_07_49_32_f8ba0e88ddd1_ddl_add_comments_descendant_count_column.py b/migrations/versions/2023_01_03_07_49_32_f8ba0e88ddd1_ddl_add_comments_descendant_count_column.py index 70cd23037..c089f2519 100644 --- a/migrations/versions/2023_01_03_07_49_32_f8ba0e88ddd1_ddl_add_comments_descendant_count_column.py +++ b/migrations/versions/2023_01_03_07_49_32_f8ba0e88ddd1_ddl_add_comments_descendant_count_column.py @@ -17,17 +17,17 @@ depends_on = None def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('comments', sa.Column( + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('comments', sa.Column( 'descendant_count', sa.Integer(), nullable=False, server_default=sa.text('0') )) - # ### end Alembic commands ### + # ### end Alembic commands ### def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('comments', 'descendant_count') - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('comments', 'descendant_count') + # ### end Alembic commands ### diff --git a/migrations/versions/2023_01_03_07_59_56_1f30a37b08a0_dml_populate_comments_descendant_count_.py b/migrations/versions/2023_01_03_07_59_56_1f30a37b08a0_dml_populate_comments_descendant_count_.py index f9bab2772..0e9f78a9b 100644 --- a/migrations/versions/2023_01_03_07_59_56_1f30a37b08a0_dml_populate_comments_descendant_count_.py +++ b/migrations/versions/2023_01_03_07_59_56_1f30a37b08a0_dml_populate_comments_descendant_count_.py @@ -22,9 +22,9 @@ branch_labels = None depends_on = None def upgrade(): - db =Session(bind=op.get_bind()) + db: Session = Session(bind=op.get_bind()) bulk_recompute_descendant_counts(lambda q: q, db) def downgrade(): - db =Session(bind=op.get_bind()) + db: Session = Session(bind=op.get_bind()) db.execute(update(Comment).values(descendant_count=0)) diff --git a/migrations/versions/2023_02_08_22_04_15_ba8a214736eb_remove_users_song.py b/migrations/versions/2023_02_08_22_04_15_ba8a214736eb_remove_users_song.py index bfe6322f2..b22eb82a1 100644 --- a/migrations/versions/2023_02_08_22_04_15_ba8a214736eb_remove_users_song.py +++ b/migrations/versions/2023_02_08_22_04_15_ba8a214736eb_remove_users_song.py @@ -17,12 +17,12 @@ depends_on = None def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('users', 'song') - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('users', 'song') + # ### end Alembic commands ### def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('users', sa.Column('song', sa.VARCHAR(length=50), autoincrement=False, nullable=True)) - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('users', sa.Column('song', sa.VARCHAR(length=50), autoincrement=False, nullable=True)) + # ### end Alembic commands ### diff --git a/migrations/versions/2023_02_17_03_03_40_85458909736a_support_infinite_length_submission_and_.py b/migrations/versions/2023_02_17_03_03_40_85458909736a_support_infinite_length_submission_and_.py index 5debf203b..597402c10 100644 --- a/migrations/versions/2023_02_17_03_03_40_85458909736a_support_infinite_length_submission_and_.py +++ b/migrations/versions/2023_02_17_03_03_40_85458909736a_support_infinite_length_submission_and_.py @@ -17,50 +17,50 @@ depends_on = None def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('comments', 'body', - existing_type=sa.VARCHAR(length=40000), - type_=sa.Text(), - existing_nullable=True) - op.alter_column('comments', 'body_html', - existing_type=sa.VARCHAR(length=40000), - type_=sa.Text(), - nullable=False) - op.alter_column('submissions', 'body', - existing_type=sa.VARCHAR(length=40000), - type_=sa.Text(), - existing_nullable=True) - op.alter_column('submissions', 'body_html', - existing_type=sa.VARCHAR(length=40000), - type_=sa.Text(), - existing_nullable=True) - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('comments', 'body', + existing_type=sa.VARCHAR(length=40000), + type_=sa.Text(), + existing_nullable=True) + op.alter_column('comments', 'body_html', + existing_type=sa.VARCHAR(length=40000), + type_=sa.Text(), + nullable=False) + op.alter_column('submissions', 'body', + existing_type=sa.VARCHAR(length=40000), + type_=sa.Text(), + existing_nullable=True) + op.alter_column('submissions', 'body_html', + existing_type=sa.VARCHAR(length=40000), + type_=sa.Text(), + existing_nullable=True) + # ### end Alembic commands ### def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.alter_column('submissions', 'body_html', - existing_type=sa.Text(), - type_=sa.VARCHAR(length=40000), - existing_nullable=True) - op.alter_column('submissions', 'body', - existing_type=sa.Text(), - type_=sa.VARCHAR(length=40000), - existing_nullable=True) - op.alter_column('oauth_apps', 'redirect_uri', - existing_type=sa.String(length=50), - type_=sa.VARCHAR(length=4096), - existing_nullable=False) - op.alter_column('oauth_apps', 'client_id', - existing_type=sa.String(), - type_=sa.CHAR(length=64), - existing_nullable=True) - op.alter_column('comments', 'body_html', - existing_type=sa.Text(), - type_=sa.VARCHAR(length=40000), - nullable=True) - op.alter_column('comments', 'body', - existing_type=sa.Text(), - type_=sa.VARCHAR(length=40000), - existing_nullable=True) - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('submissions', 'body_html', + existing_type=sa.Text(), + type_=sa.VARCHAR(length=40000), + existing_nullable=True) + op.alter_column('submissions', 'body', + existing_type=sa.Text(), + type_=sa.VARCHAR(length=40000), + existing_nullable=True) + op.alter_column('oauth_apps', 'redirect_uri', + existing_type=sa.String(length=50), + type_=sa.VARCHAR(length=4096), + existing_nullable=False) + op.alter_column('oauth_apps', 'client_id', + existing_type=sa.String(), + type_=sa.CHAR(length=64), + existing_nullable=True) + op.alter_column('comments', 'body_html', + existing_type=sa.Text(), + type_=sa.VARCHAR(length=40000), + nullable=True) + op.alter_column('comments', 'body', + existing_type=sa.Text(), + type_=sa.VARCHAR(length=40000), + existing_nullable=True) + # ### end Alembic commands ### diff --git a/migrations/versions/2023_03_21_15_42_19_8b97d5de5050_create_scheduled_tasks.py b/migrations/versions/2023_03_21_15_42_19_8b97d5de5050_create_scheduled_tasks.py index b2b8e2c23..75dbb3c42 100644 --- a/migrations/versions/2023_03_21_15_42_19_8b97d5de5050_create_scheduled_tasks.py +++ b/migrations/versions/2023_03_21_15_42_19_8b97d5de5050_create_scheduled_tasks.py @@ -17,65 +17,65 @@ depends_on = None def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('tasks_repeatable', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('author_id', sa.Integer(), nullable=False), - sa.Column('type_id', sa.SmallInteger(), nullable=False), - sa.Column('enabled', sa.Boolean(), nullable=False), - sa.Column('run_state', sa.SmallInteger(), nullable=False), - sa.Column('run_time_last', sa.DateTime(), nullable=True), - sa.Column('frequency_day', sa.SmallInteger(), nullable=False), - sa.Column('time_of_day_utc', sa.Time(), nullable=False), - sa.Column('created_utc', sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(['author_id'], ['users.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('tasks_repeatable_python', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('import_path', sa.String(), nullable=False), - sa.Column('callable', sa.String(), nullable=False), - sa.ForeignKeyConstraint(['id'], ['tasks_repeatable.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('tasks_repeatable_runs', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('task_id', sa.Integer(), nullable=False), - sa.Column('manual', sa.Boolean(), nullable=False), - sa.Column('traceback_str', sa.Text(), nullable=True), - sa.Column('completed_utc', sa.DateTime(), nullable=True), - sa.Column('created_utc', sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(['task_id'], ['tasks_repeatable.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_table('tasks_repeatable_scheduled_submissions', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('author_id_submission', sa.Integer(), nullable=False), - sa.Column('ghost', sa.Boolean(), nullable=False), - sa.Column('private', sa.Boolean(), nullable=False), - sa.Column('over_18', sa.Boolean(), nullable=False), - sa.Column('is_bot', sa.Boolean(), nullable=False), - sa.Column('title', sa.String(length=500), nullable=False), - sa.Column('url', sa.String(), nullable=True), - sa.Column('body', sa.Text(), nullable=True), - sa.Column('body_html', sa.Text(), nullable=True), - sa.Column('flair', sa.String(), nullable=True), - sa.Column('embed_url', sa.String(), nullable=True), - sa.ForeignKeyConstraint(['author_id_submission'], ['users.id'], ), - sa.ForeignKeyConstraint(['id'], ['tasks_repeatable.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.add_column('submissions', sa.Column('task_id', sa.Integer(), nullable=True)) - op.create_foreign_key(None, 'submissions', 'tasks_repeatable_scheduled_submissions', ['task_id'], ['id']) - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('tasks_repeatable', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('author_id', sa.Integer(), nullable=False), + sa.Column('type_id', sa.SmallInteger(), nullable=False), + sa.Column('enabled', sa.Boolean(), nullable=False), + sa.Column('run_state', sa.SmallInteger(), nullable=False), + sa.Column('run_time_last', sa.DateTime(), nullable=True), + sa.Column('frequency_day', sa.SmallInteger(), nullable=False), + sa.Column('time_of_day_utc', sa.Time(), nullable=False), + sa.Column('created_utc', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['author_id'], ['users.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('tasks_repeatable_python', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('import_path', sa.String(), nullable=False), + sa.Column('callable', sa.String(), nullable=False), + sa.ForeignKeyConstraint(['id'], ['tasks_repeatable.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('tasks_repeatable_runs', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('task_id', sa.Integer(), nullable=False), + sa.Column('manual', sa.Boolean(), nullable=False), + sa.Column('traceback_str', sa.Text(), nullable=True), + sa.Column('completed_utc', sa.DateTime(), nullable=True), + sa.Column('created_utc', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['task_id'], ['tasks_repeatable.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.create_table('tasks_repeatable_scheduled_submissions', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('author_id_submission', sa.Integer(), nullable=False), + sa.Column('ghost', sa.Boolean(), nullable=False), + sa.Column('private', sa.Boolean(), nullable=False), + sa.Column('over_18', sa.Boolean(), nullable=False), + sa.Column('is_bot', sa.Boolean(), nullable=False), + sa.Column('title', sa.String(length=500), nullable=False), + sa.Column('url', sa.String(), nullable=True), + sa.Column('body', sa.Text(), nullable=True), + sa.Column('body_html', sa.Text(), nullable=True), + sa.Column('flair', sa.String(), nullable=True), + sa.Column('embed_url', sa.String(), nullable=True), + sa.ForeignKeyConstraint(['author_id_submission'], ['users.id'], ), + sa.ForeignKeyConstraint(['id'], ['tasks_repeatable.id'], ), + sa.PrimaryKeyConstraint('id') + ) + op.add_column('submissions', sa.Column('task_id', sa.Integer(), nullable=True)) + op.create_foreign_key(None, 'submissions', 'tasks_repeatable_scheduled_submissions', ['task_id'], ['id']) + # ### end Alembic commands ### def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint(None, 'submissions', type_='foreignkey') - op.drop_column('submissions', 'task_id') - op.drop_table('tasks_repeatable_scheduled_submissions') - op.drop_table('tasks_repeatable_runs') - op.drop_table('tasks_repeatable_python') - op.drop_table('tasks_repeatable') - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint(None, 'submissions', type_='foreignkey') + op.drop_column('submissions', 'task_id') + op.drop_table('tasks_repeatable_scheduled_submissions') + op.drop_table('tasks_repeatable_runs') + op.drop_table('tasks_repeatable_python') + op.drop_table('tasks_repeatable') + # ### end Alembic commands ### diff --git a/migrations/versions/2023_03_30_05_36_17_6b6c1b21a487_remove_holes.py b/migrations/versions/2023_03_30_05_36_17_6b6c1b21a487_remove_holes.py index f6d908e62..8c1baa197 100644 --- a/migrations/versions/2023_03_30_05_36_17_6b6c1b21a487_remove_holes.py +++ b/migrations/versions/2023_03_30_05_36_17_6b6c1b21a487_remove_holes.py @@ -19,71 +19,71 @@ depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! (adjusted -@TLSM) ### - op.drop_index('fki_exile_exiler_fkey', table_name='exiles') - op.drop_index('fki_exile_sub_fkey', table_name='exiles') - op.drop_table('exiles') + op.drop_index('fki_exile_exiler_fkey', table_name='exiles') + op.drop_index('fki_exile_sub_fkey', table_name='exiles') + op.drop_table('exiles') - op.drop_index('fki_mod_sub_fkey', table_name='mods') - op.drop_table('mods') + op.drop_index('fki_mod_sub_fkey', table_name='mods') + op.drop_table('mods') - op.drop_index('fki_sub_blocks_sub_fkey', table_name='sub_blocks') - op.drop_table('sub_blocks') + op.drop_index('fki_sub_blocks_sub_fkey', table_name='sub_blocks') + op.drop_table('sub_blocks') - op.drop_constraint('sub_fkey', 'submissions', type_='foreignkey') - op.drop_column('submissions', 'sub') - op.drop_column('users', 'subs_created') + op.drop_constraint('sub_fkey', 'submissions', type_='foreignkey') + op.drop_column('submissions', 'sub') + op.drop_column('users', 'subs_created') - op.drop_index('subs_idx', table_name='subs') - op.drop_table('subs') + op.drop_index('subs_idx', table_name='subs') + op.drop_table('subs') - op.execute("DELETE FROM modactions WHERE kind = 'move_hole'") + op.execute("DELETE FROM modactions WHERE kind = 'move_hole'") def downgrade(): - # ### commands auto generated by Alembic - please adjust! (adjusted -@TLSM) ### - op.create_table('subs', - sa.Column('name', sa.VARCHAR(length=20), autoincrement=False, nullable=False), - sa.Column('sidebar', sa.VARCHAR(length=500), autoincrement=False, nullable=True), - sa.Column('sidebar_html', sa.VARCHAR(length=1000), autoincrement=False, nullable=True), - sa.Column('sidebarurl', sa.VARCHAR(length=60), autoincrement=False, nullable=True), - sa.Column('bannerurl', sa.VARCHAR(length=60), autoincrement=False, nullable=True), - sa.Column('css', sa.VARCHAR(length=4000), autoincrement=False, nullable=True), - sa.PrimaryKeyConstraint('name', name='subs_pkey'), - postgresql_ignore_search_path=False - ) - op.create_index('subs_idx', 'subs', ['name'], unique=False) + # ### commands auto generated by Alembic - please adjust! (adjusted -@TLSM) ### + op.create_table('subs', + sa.Column('name', sa.VARCHAR(length=20), autoincrement=False, nullable=False), + sa.Column('sidebar', sa.VARCHAR(length=500), autoincrement=False, nullable=True), + sa.Column('sidebar_html', sa.VARCHAR(length=1000), autoincrement=False, nullable=True), + sa.Column('sidebarurl', sa.VARCHAR(length=60), autoincrement=False, nullable=True), + sa.Column('bannerurl', sa.VARCHAR(length=60), autoincrement=False, nullable=True), + sa.Column('css', sa.VARCHAR(length=4000), autoincrement=False, nullable=True), + sa.PrimaryKeyConstraint('name', name='subs_pkey'), + postgresql_ignore_search_path=False + ) + op.create_index('subs_idx', 'subs', ['name'], unique=False) - op.add_column('users', sa.Column('subs_created', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=False)) - op.add_column('submissions', sa.Column('sub', sa.VARCHAR(length=20), autoincrement=False, nullable=True)) - op.create_foreign_key('sub_fkey', 'submissions', 'subs', ['sub'], ['name']) + op.add_column('users', sa.Column('subs_created', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=False)) + op.add_column('submissions', sa.Column('sub', sa.VARCHAR(length=20), autoincrement=False, nullable=True)) + op.create_foreign_key('sub_fkey', 'submissions', 'subs', ['sub'], ['name']) - op.create_table('sub_blocks', - sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('sub', sa.VARCHAR(length=20), autoincrement=False, nullable=False), - sa.ForeignKeyConstraint(['sub'], ['subs.name'], name='sub_blocks_sub_fkey'), - sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='sub_blocks_user_fkey'), - sa.PrimaryKeyConstraint('user_id', 'sub', name='sub_blocks_pkey') - ) - op.create_index('fki_sub_blocks_sub_fkey', 'sub_blocks', ['sub'], unique=False) + op.create_table('sub_blocks', + sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column('sub', sa.VARCHAR(length=20), autoincrement=False, nullable=False), + sa.ForeignKeyConstraint(['sub'], ['subs.name'], name='sub_blocks_sub_fkey'), + sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='sub_blocks_user_fkey'), + sa.PrimaryKeyConstraint('user_id', 'sub', name='sub_blocks_pkey') + ) + op.create_index('fki_sub_blocks_sub_fkey', 'sub_blocks', ['sub'], unique=False) - op.create_table('mods', - sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('sub', sa.VARCHAR(length=20), autoincrement=False, nullable=False), - sa.Column('created_utc', sa.INTEGER(), autoincrement=False, nullable=False), - sa.ForeignKeyConstraint(['sub'], ['subs.name'], name='mod_sub_fkey'), - sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='user_mod_fkey'), - sa.PrimaryKeyConstraint('user_id', 'sub', name='mods_pkey') - ) - op.create_index('fki_mod_sub_fkey', 'mods', ['sub'], unique=False) + op.create_table('mods', + sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column('sub', sa.VARCHAR(length=20), autoincrement=False, nullable=False), + sa.Column('created_utc', sa.INTEGER(), autoincrement=False, nullable=False), + sa.ForeignKeyConstraint(['sub'], ['subs.name'], name='mod_sub_fkey'), + sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='user_mod_fkey'), + sa.PrimaryKeyConstraint('user_id', 'sub', name='mods_pkey') + ) + op.create_index('fki_mod_sub_fkey', 'mods', ['sub'], unique=False) - op.create_table('exiles', - sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False), - sa.Column('sub', sa.VARCHAR(length=20), autoincrement=False, nullable=False), - sa.Column('exiler_id', sa.INTEGER(), autoincrement=False, nullable=False), - sa.ForeignKeyConstraint(['exiler_id'], ['users.id'], name='exile_exiler_fkey'), - sa.ForeignKeyConstraint(['sub'], ['subs.name'], name='exile_sub_fkey'), - sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='exile_user_fkey'), - sa.PrimaryKeyConstraint('user_id', 'sub', name='exiles_pkey') - ) - op.create_index('fki_exile_sub_fkey', 'exiles', ['sub'], unique=False) - op.create_index('fki_exile_exiler_fkey', 'exiles', ['exiler_id'], unique=False) + op.create_table('exiles', + sa.Column('user_id', sa.INTEGER(), autoincrement=False, nullable=False), + sa.Column('sub', sa.VARCHAR(length=20), autoincrement=False, nullable=False), + sa.Column('exiler_id', sa.INTEGER(), autoincrement=False, nullable=False), + sa.ForeignKeyConstraint(['exiler_id'], ['users.id'], name='exile_exiler_fkey'), + sa.ForeignKeyConstraint(['sub'], ['subs.name'], name='exile_sub_fkey'), + sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='exile_user_fkey'), + sa.PrimaryKeyConstraint('user_id', 'sub', name='exiles_pkey') + ) + op.create_index('fki_exile_sub_fkey', 'exiles', ['sub'], unique=False) + op.create_index('fki_exile_exiler_fkey', 'exiles', ['exiler_id'], unique=False) diff --git a/migrations/versions/2023_04_22_07_57_45_0cd3a7ebef3f_add_cron_labels.py b/migrations/versions/2023_04_22_07_57_45_0cd3a7ebef3f_add_cron_labels.py index 5ce1ea2a5..2708e6ae3 100644 --- a/migrations/versions/2023_04_22_07_57_45_0cd3a7ebef3f_add_cron_labels.py +++ b/migrations/versions/2023_04_22_07_57_45_0cd3a7ebef3f_add_cron_labels.py @@ -17,14 +17,14 @@ depends_on = None def upgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('tasks_repeatable', sa.Column('label', sa.String(), nullable=True)) - op.create_unique_constraint(None, 'tasks_repeatable', ['label']) - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('tasks_repeatable', sa.Column('label', sa.String(), nullable=True)) + op.create_unique_constraint(None, 'tasks_repeatable', ['label']) + # ### end Alembic commands ### def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint(None, 'tasks_repeatable', type_='unique') - op.drop_column('tasks_repeatable', 'label') - # ### end Alembic commands ### + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint(None, 'tasks_repeatable', type_='unique') + op.drop_column('tasks_repeatable', 'label') + # ### end Alembic commands ### diff --git a/migrations/versions/2023_04_22_10_48_16_b2373d7b1b84_add_persistent_volunteer_janitor_data_.py b/migrations/versions/2023_04_22_10_48_16_b2373d7b1b84_add_persistent_volunteer_janitor_data_.py index fc58c7ee4..00be53e68 100644 --- a/migrations/versions/2023_04_22_10_48_16_b2373d7b1b84_add_persistent_volunteer_janitor_data_.py +++ b/migrations/versions/2023_04_22_10_48_16_b2373d7b1b84_add_persistent_volunteer_janitor_data_.py @@ -17,22 +17,22 @@ depends_on = None def upgrade(): - # manually adjusted to introduce our intended defaults - op.add_column('comments', sa.Column('volunteer_janitor_badness', sa.Float())) - op.execute("UPDATE comments SET volunteer_janitor_badness = 0.5") - op.alter_column('comments', 'volunteer_janitor_badness', nullable=False) + # manually adjusted to introduce our intended defaults + op.add_column('comments', sa.Column('volunteer_janitor_badness', sa.Float())) + op.execute("UPDATE comments SET volunteer_janitor_badness = 0.5") + op.alter_column('comments', 'volunteer_janitor_badness', nullable=False) - op.add_column('users', sa.Column('volunteer_janitor_correctness', sa.Float())) - op.execute("UPDATE users SET volunteer_janitor_correctness = 0") - op.alter_column('users', 'volunteer_janitor_correctness', nullable=False) + op.add_column('users', sa.Column('volunteer_janitor_correctness', sa.Float())) + op.execute("UPDATE users SET volunteer_janitor_correctness = 0") + op.alter_column('users', 'volunteer_janitor_correctness', nullable=False) def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('users', schema=None) as batch_op: - batch_op.drop_column('volunteer_janitor_correctness') + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('users', schema=None) as batch_op: + batch_op.drop_column('volunteer_janitor_correctness') - with op.batch_alter_table('comments', schema=None) as batch_op: - batch_op.drop_column('volunteer_janitor_badness') + with op.batch_alter_table('comments', schema=None) as batch_op: + batch_op.drop_column('volunteer_janitor_badness') - # ### end Alembic commands ### + # ### end Alembic commands ### diff --git a/migrations/versions/2023_04_22_11_33_50_6403c9151c12_recalculate_all_volunteer_janitor_.py b/migrations/versions/2023_04_22_11_33_50_6403c9151c12_recalculate_all_volunteer_janitor_.py index ff25da4a2..fc6c54bc4 100644 --- a/migrations/versions/2023_04_22_11_33_50_6403c9151c12_recalculate_all_volunteer_janitor_.py +++ b/migrations/versions/2023_04_22_11_33_50_6403c9151c12_recalculate_all_volunteer_janitor_.py @@ -19,10 +19,10 @@ depends_on = None def upgrade(): - # this is now disabled because this code is no longer compatible with this version of the DB - #volunteer_janitor_recalc_all_comments(Session(bind=op.get_bind())) - pass + # this is now disabled because this code is no longer compatible with this version of the DB + #volunteer_janitor_recalc_all_comments(Session(bind=op.get_bind())) + pass def downgrade(): - pass + pass diff --git a/migrations/versions/2023_06_11_09_09_00_8337558f4f36_move_deleted_utc_into_state_user_.py b/migrations/versions/2023_06_11_09_09_00_8337558f4f36_move_deleted_utc_into_state_user_.py index 8510a9f9f..d130c8114 100644 --- a/migrations/versions/2023_06_11_09_09_00_8337558f4f36_move_deleted_utc_into_state_user_.py +++ b/migrations/versions/2023_06_11_09_09_00_8337558f4f36_move_deleted_utc_into_state_user_.py @@ -17,76 +17,76 @@ depends_on = None def upgrade(): - op.add_column('comments', sa.Column('state_user_deleted_utc', sa.DateTime(timezone=True), nullable=True)) - op.add_column('submissions', sa.Column('state_user_deleted_utc', sa.DateTime(timezone=True), nullable=True)) + op.add_column('comments', sa.Column('state_user_deleted_utc', sa.DateTime(timezone=True), nullable=True)) + op.add_column('submissions', sa.Column('state_user_deleted_utc', sa.DateTime(timezone=True), nullable=True)) - op.drop_index('subimssion_binary_group_idx', table_name='submissions') - op.drop_index('submission_isdeleted_idx', table_name='submissions') - op.drop_index('submission_new_sort_idx', table_name='submissions') + op.drop_index('subimssion_binary_group_idx', table_name='submissions') + op.drop_index('submission_isdeleted_idx', table_name='submissions') + op.drop_index('submission_new_sort_idx', table_name='submissions') - op.execute(""" - UPDATE comments - SET state_user_deleted_utc = - CASE - WHEN deleted_utc > 0 THEN - (timestamp 'epoch' + deleted_utc * interval '1 second') at time zone 'utc' - ELSE NULL - END - """) + op.execute(""" + UPDATE comments + SET state_user_deleted_utc = + CASE + WHEN deleted_utc > 0 THEN + (timestamp 'epoch' + deleted_utc * interval '1 second') at time zone 'utc' + ELSE NULL + END + """) - op.execute(""" - UPDATE submissions - SET state_user_deleted_utc = - CASE - WHEN deleted_utc > 0 THEN - (timestamp 'epoch' + deleted_utc * interval '1 second') at time zone 'utc' - ELSE NULL - END - """) + op.execute(""" + UPDATE submissions + SET state_user_deleted_utc = + CASE + WHEN deleted_utc > 0 THEN + (timestamp 'epoch' + deleted_utc * interval '1 second') at time zone 'utc' + ELSE NULL + END + """) - op.drop_column('comments', 'deleted_utc') - op.drop_column('submissions', 'deleted_utc') + op.drop_column('comments', 'deleted_utc') + op.drop_column('submissions', 'deleted_utc') - op.create_index('subimssion_binary_group_idx', 'submissions', ['is_banned', 'state_user_deleted_utc', 'over_18'], unique=False) - op.create_index('submission_isdeleted_idx', 'submissions', ['state_user_deleted_utc'], unique=False) - op.create_index('submission_new_sort_idx', 'submissions', ['is_banned', 'state_user_deleted_utc', sa.text('created_utc DESC'), 'over_18'], unique=False) + op.create_index('subimssion_binary_group_idx', 'submissions', ['is_banned', 'state_user_deleted_utc', 'over_18'], unique=False) + op.create_index('submission_isdeleted_idx', 'submissions', ['state_user_deleted_utc'], unique=False) + op.create_index('submission_new_sort_idx', 'submissions', ['is_banned', 'state_user_deleted_utc', sa.text('created_utc DESC'), 'over_18'], unique=False) def downgrade(): - op.add_column('comments', sa.Column('deleted_utc', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=True)) - op.add_column('submissions', sa.Column('deleted_utc', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=True)) + op.add_column('comments', sa.Column('deleted_utc', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=True)) + op.add_column('submissions', sa.Column('deleted_utc', sa.INTEGER(), server_default=sa.text('0'), autoincrement=False, nullable=True)) - op.drop_index('submission_new_sort_idx', table_name='submissions') - op.drop_index('submission_isdeleted_idx', table_name='submissions') - op.drop_index('subimssion_binary_group_idx', table_name='submissions') + op.drop_index('submission_new_sort_idx', table_name='submissions') + op.drop_index('submission_isdeleted_idx', table_name='submissions') + op.drop_index('subimssion_binary_group_idx', table_name='submissions') - op.execute(""" - UPDATE comments - SET deleted_utc = - COALESCE( - EXTRACT(EPOCH FROM state_user_deleted_utc)::integer, - 0 - ) - """) - - op.execute(""" - UPDATE submissions - SET deleted_utc = - COALESCE( - EXTRACT(EPOCH FROM state_user_deleted_utc)::integer, - 0 - ) - """) + op.execute(""" + UPDATE comments + SET deleted_utc = + COALESCE( + EXTRACT(EPOCH FROM state_user_deleted_utc)::integer, + 0 + ) + """) + + op.execute(""" + UPDATE submissions + SET deleted_utc = + COALESCE( + EXTRACT(EPOCH FROM state_user_deleted_utc)::integer, + 0 + ) + """) - op.alter_column('comments', 'deleted_utc', nullable=False) - op.alter_column('submissions', 'deleted_utc', nullable=False) + op.alter_column('comments', 'deleted_utc', nullable=False) + op.alter_column('submissions', 'deleted_utc', nullable=False) - op.drop_column('comments', 'state_user_deleted_utc') - op.drop_column('submissions', 'state_user_deleted_utc') + op.drop_column('comments', 'state_user_deleted_utc') + op.drop_column('submissions', 'state_user_deleted_utc') - op.create_index('submission_new_sort_idx', 'submissions', ['is_banned', 'deleted_utc', 'created_utc', 'over_18'], unique=False) - op.create_index('submission_isdeleted_idx', 'submissions', ['deleted_utc'], unique=False) - op.create_index('subimssion_binary_group_idx', 'submissions', ['is_banned', 'deleted_utc', 'over_18'], unique=False) + op.create_index('submission_new_sort_idx', 'submissions', ['is_banned', 'deleted_utc', 'created_utc', 'over_18'], unique=False) + op.create_index('submission_isdeleted_idx', 'submissions', ['deleted_utc'], unique=False) + op.create_index('subimssion_binary_group_idx', 'submissions', ['is_banned', 'deleted_utc', 'over_18'], unique=False) diff --git a/migrations/versions/2023_06_24_02_37_51_4bb8194c8ac0_ban_comment_remove_comment_and_the_same_.py b/migrations/versions/2023_06_24_02_37_51_4bb8194c8ac0_ban_comment_remove_comment_and_the_same_.py index 536976db7..38b2ef3d6 100644 --- a/migrations/versions/2023_06_24_02_37_51_4bb8194c8ac0_ban_comment_remove_comment_and_the_same_.py +++ b/migrations/versions/2023_06_24_02_37_51_4bb8194c8ac0_ban_comment_remove_comment_and_the_same_.py @@ -17,17 +17,17 @@ depends_on = None def upgrade(): - # update for comments - op.execute(sa.text("""UPDATE modactions SET kind = 'remove_comment' WHERE kind = 'ban_comment'""")) - op.execute(sa.text("""UPDATE modactions SET kind = 'unremove_comment' WHERE kind = 'unban_comment'""")) - # update for posts - op.execute(sa.text("""UPDATE modactions SET kind = 'remove_post' WHERE kind = 'ban_post'""")) - op.execute(sa.text("""UPDATE modactions SET kind = 'unremove_post' WHERE kind = 'unban_post'""")) + # update for comments + op.execute(sa.text("""UPDATE modactions SET kind = 'remove_comment' WHERE kind = 'ban_comment'""")) + op.execute(sa.text("""UPDATE modactions SET kind = 'unremove_comment' WHERE kind = 'unban_comment'""")) + # update for posts + op.execute(sa.text("""UPDATE modactions SET kind = 'remove_post' WHERE kind = 'ban_post'""")) + op.execute(sa.text("""UPDATE modactions SET kind = 'unremove_post' WHERE kind = 'unban_post'""")) def downgrade(): - # rollback for comments - op.execute(sa.text("""UPDATE modactions SET kind = 'ban_comment' WHERE kind = 'remove_comment'""")) - op.execute(sa.text("""UPDATE modactions SET kind = 'unban_comment' WHERE kind = 'unremove_comment'""")) - # rollback for posts - op.execute(sa.text("""UPDATE modactions SET kind = 'ban_post' WHERE kind = 'remove_post'""")) - op.execute(sa.text("""UPDATE modactions SET kind = 'unban_post' WHERE kind = 'unremove_post'""")) \ No newline at end of file + # rollback for comments + op.execute(sa.text("""UPDATE modactions SET kind = 'ban_comment' WHERE kind = 'remove_comment'""")) + op.execute(sa.text("""UPDATE modactions SET kind = 'unban_comment' WHERE kind = 'unremove_comment'""")) + # rollback for posts + op.execute(sa.text("""UPDATE modactions SET kind = 'ban_post' WHERE kind = 'remove_post'""")) + op.execute(sa.text("""UPDATE modactions SET kind = 'unban_post' WHERE kind = 'unremove_post'""")) diff --git a/migrations/versions/2023_06_25_07_09_36_ea282d7c711c_rejigger_of_the_mod_report_comment_post_.py b/migrations/versions/2023_06_25_07_09_36_ea282d7c711c_rejigger_of_the_mod_report_comment_post_.py index 5c5cc2cd9..b23c58462 100644 --- a/migrations/versions/2023_06_25_07_09_36_ea282d7c711c_rejigger_of_the_mod_report_comment_post_.py +++ b/migrations/versions/2023_06_25_07_09_36_ea282d7c711c_rejigger_of_the_mod_report_comment_post_.py @@ -17,217 +17,217 @@ depends_on = None def upgrade(): - state_mod_enum = sa.Enum('VISIBLE', 'FILTERED', 'REMOVED', name='statemod', create_type=False) - state_report_enum = sa.Enum('UNREPORTED', 'RESOLVED', 'REPORTED', 'IGNORED', name='statereport', create_type=False) + state_mod_enum = sa.Enum('VISIBLE', 'FILTERED', 'REMOVED', name='statemod', create_type=False) + state_report_enum = sa.Enum('UNREPORTED', 'RESOLVED', 'REPORTED', 'IGNORED', name='statereport', create_type=False) - state_mod_enum.create(op.get_bind(), checkfirst=True) - state_report_enum.create(op.get_bind(), checkfirst=True) + state_mod_enum.create(op.get_bind(), checkfirst=True) + state_report_enum.create(op.get_bind(), checkfirst=True) - op.add_column('comments', sa.Column('state_mod', state_mod_enum, nullable=True)) - op.add_column('comments', sa.Column('state_mod_set_by', sa.String(), nullable=True)) - op.add_column('comments', sa.Column('state_report', state_report_enum, nullable=True)) - op.drop_index('fki_comment_approver_fkey', table_name='comments') - op.drop_constraint('comment_approver_fkey', 'comments', type_='foreignkey') + op.add_column('comments', sa.Column('state_mod', state_mod_enum, nullable=True)) + op.add_column('comments', sa.Column('state_mod_set_by', sa.String(), nullable=True)) + op.add_column('comments', sa.Column('state_report', state_report_enum, nullable=True)) + op.drop_index('fki_comment_approver_fkey', table_name='comments') + op.drop_constraint('comment_approver_fkey', 'comments', type_='foreignkey') - # If `is_banned`, set `state_mod` to the `REMOVED` enum - # otherwise, if `filter_state` is `FILTERED`, set `state_mod` to the `FILTERED` enum - # otherwise, set `state_mod` to the `VISIBLE` enum - op.execute(""" - UPDATE comments - SET state_mod = CASE - WHEN is_banned THEN 'REMOVED'::statemod - WHEN filter_state = 'FILTERED' THEN 'FILTERED'::statemod - ELSE 'VISIBLE'::statemod - END - """) + # If `is_banned`, set `state_mod` to the `REMOVED` enum + # otherwise, if `filter_state` is `FILTERED`, set `state_mod` to the `FILTERED` enum + # otherwise, set `state_mod` to the `VISIBLE` enum + op.execute(""" + UPDATE comments + SET state_mod = CASE + WHEN is_banned THEN 'REMOVED'::statemod + WHEN filter_state = 'FILTERED' THEN 'FILTERED'::statemod + ELSE 'VISIBLE'::statemod + END + """) - # if `state_mod` is `REMOVED`, set `state_mod_set_by` to `ban_reason` - # otherwise, if `state_mod` is `VISIBLE`, set `state_mod_set_by` to the `username` of the `users` table, indexed by `is_approved == users.id` - op.execute(""" - UPDATE comments - SET state_mod_set_by = CASE - WHEN state_mod = 'REMOVED' THEN ban_reason - WHEN state_mod = 'VISIBLE' THEN (SELECT username FROM users WHERE id = is_approved) - END - """) + # if `state_mod` is `REMOVED`, set `state_mod_set_by` to `ban_reason` + # otherwise, if `state_mod` is `VISIBLE`, set `state_mod_set_by` to the `username` of the `users` table, indexed by `is_approved == users.id` + op.execute(""" + UPDATE comments + SET state_mod_set_by = CASE + WHEN state_mod = 'REMOVED' THEN ban_reason + WHEN state_mod = 'VISIBLE' THEN (SELECT username FROM users WHERE id = is_approved) + END + """) - # if `filter_state` is `IGNORED`, set `state_report` to the `IGNORED` enum - # otherwise, if `filter_state` is `REPORTED`, set `state_report` to the `REPORTED` enum - # otherwise, if `state_mod_set_by` is non-NULL, set `state_report` to the `RESOLVED` enum - # otherwise, set `state_report` to the `UNREPORTED` enum - op.execute(""" - UPDATE comments - SET state_report = CASE - WHEN filter_state = 'IGNORED' THEN 'IGNORED'::statereport - WHEN filter_state = 'REPORTED' THEN 'REPORTED'::statereport - WHEN state_mod_set_by IS NOT NULL THEN 'RESOLVED'::statereport - ELSE 'UNREPORTED'::statereport - END - """) + # if `filter_state` is `IGNORED`, set `state_report` to the `IGNORED` enum + # otherwise, if `filter_state` is `REPORTED`, set `state_report` to the `REPORTED` enum + # otherwise, if `state_mod_set_by` is non-NULL, set `state_report` to the `RESOLVED` enum + # otherwise, set `state_report` to the `UNREPORTED` enum + op.execute(""" + UPDATE comments + SET state_report = CASE + WHEN filter_state = 'IGNORED' THEN 'IGNORED'::statereport + WHEN filter_state = 'REPORTED' THEN 'REPORTED'::statereport + WHEN state_mod_set_by IS NOT NULL THEN 'RESOLVED'::statereport + ELSE 'UNREPORTED'::statereport + END + """) - op.alter_column('comments', 'state_mod', nullable=False) - op.alter_column('comments', 'state_report', nullable=False) + op.alter_column('comments', 'state_mod', nullable=False) + op.alter_column('comments', 'state_report', nullable=False) - op.drop_column('comments', 'is_banned') - op.drop_column('comments', 'ban_reason') - op.drop_column('comments', 'is_approved') - op.drop_column('comments', 'filter_state') + op.drop_column('comments', 'is_banned') + op.drop_column('comments', 'ban_reason') + op.drop_column('comments', 'is_approved') + op.drop_column('comments', 'filter_state') - op.add_column('submissions', sa.Column('state_mod', state_mod_enum, nullable=True)) - op.add_column('submissions', sa.Column('state_mod_set_by', sa.String(), nullable=True)) - op.add_column('submissions', sa.Column('state_report', state_report_enum, nullable=True)) - op.drop_index('fki_submissions_approver_fkey', table_name='submissions') - op.drop_index('submission_isbanned_idx', table_name='submissions') - op.drop_index('subimssion_binary_group_idx', table_name='submissions') - op.create_index('subimssion_binary_group_idx', 'submissions', ['state_mod', 'state_user_deleted_utc', 'over_18'], unique=False) - op.drop_index('submission_new_sort_idx', table_name='submissions') - op.create_index('submission_new_sort_idx', 'submissions', ['state_mod', 'state_user_deleted_utc', sa.text('created_utc DESC'), 'over_18'], unique=False) - op.create_index('submission_state_mod_idx', 'submissions', ['state_mod'], unique=False) - op.drop_constraint('submissions_approver_fkey', 'submissions', type_='foreignkey') + op.add_column('submissions', sa.Column('state_mod', state_mod_enum, nullable=True)) + op.add_column('submissions', sa.Column('state_mod_set_by', sa.String(), nullable=True)) + op.add_column('submissions', sa.Column('state_report', state_report_enum, nullable=True)) + op.drop_index('fki_submissions_approver_fkey', table_name='submissions') + op.drop_index('submission_isbanned_idx', table_name='submissions') + op.drop_index('subimssion_binary_group_idx', table_name='submissions') + op.create_index('subimssion_binary_group_idx', 'submissions', ['state_mod', 'state_user_deleted_utc', 'over_18'], unique=False) + op.drop_index('submission_new_sort_idx', table_name='submissions') + op.create_index('submission_new_sort_idx', 'submissions', ['state_mod', 'state_user_deleted_utc', sa.text('created_utc DESC'), 'over_18'], unique=False) + op.create_index('submission_state_mod_idx', 'submissions', ['state_mod'], unique=False) + op.drop_constraint('submissions_approver_fkey', 'submissions', type_='foreignkey') - # If `is_banned`, set `state_mod` to the `REMOVED` enum - # otherwise, if `filter_state` is `FILTERED`, set `state_mod` to the `FILTERED` enum - # otherwise, set `state_mod` to the `VISIBLE` enum - op.execute(""" - UPDATE submissions - SET state_mod = CASE - WHEN is_banned THEN 'REMOVED'::statemod - WHEN filter_state = 'FILTERED' THEN 'FILTERED'::statemod - ELSE 'VISIBLE'::statemod - END - """) + # If `is_banned`, set `state_mod` to the `REMOVED` enum + # otherwise, if `filter_state` is `FILTERED`, set `state_mod` to the `FILTERED` enum + # otherwise, set `state_mod` to the `VISIBLE` enum + op.execute(""" + UPDATE submissions + SET state_mod = CASE + WHEN is_banned THEN 'REMOVED'::statemod + WHEN filter_state = 'FILTERED' THEN 'FILTERED'::statemod + ELSE 'VISIBLE'::statemod + END + """) - # if `state_mod` is `REMOVED`, set `state_mod_set_by` to `ban_reason` - # otherwise, if `state_mod` is `VISIBLE`, set `state_mod_set_by` to the `username` of the `users` table, indexed by `is_approved == users.id` - op.execute(""" - UPDATE submissions - SET state_mod_set_by = CASE - WHEN state_mod = 'REMOVED' THEN ban_reason - WHEN state_mod = 'VISIBLE' THEN (SELECT username FROM users WHERE id = is_approved) - END - """) + # if `state_mod` is `REMOVED`, set `state_mod_set_by` to `ban_reason` + # otherwise, if `state_mod` is `VISIBLE`, set `state_mod_set_by` to the `username` of the `users` table, indexed by `is_approved == users.id` + op.execute(""" + UPDATE submissions + SET state_mod_set_by = CASE + WHEN state_mod = 'REMOVED' THEN ban_reason + WHEN state_mod = 'VISIBLE' THEN (SELECT username FROM users WHERE id = is_approved) + END + """) - # if `filter_state` is `IGNORED`, set `state_report` to the `IGNORED` enum - # otherwise, if `filter_state` is `REPORTED`, set `state_report` to the `REPORTED` enum - # otherwise, if `state_mod_set_by` is non-NULL, set `state_report` to the `RESOLVED` enum - # otherwise, set `state_report` to the `UNREPORTED` enum - op.execute(""" - UPDATE submissions - SET state_report = CASE - WHEN filter_state = 'IGNORED' THEN 'IGNORED'::statereport - WHEN filter_state = 'REPORTED' THEN 'REPORTED'::statereport - WHEN state_mod_set_by IS NOT NULL THEN 'RESOLVED'::statereport - ELSE 'UNREPORTED'::statereport - END - """) + # if `filter_state` is `IGNORED`, set `state_report` to the `IGNORED` enum + # otherwise, if `filter_state` is `REPORTED`, set `state_report` to the `REPORTED` enum + # otherwise, if `state_mod_set_by` is non-NULL, set `state_report` to the `RESOLVED` enum + # otherwise, set `state_report` to the `UNREPORTED` enum + op.execute(""" + UPDATE submissions + SET state_report = CASE + WHEN filter_state = 'IGNORED' THEN 'IGNORED'::statereport + WHEN filter_state = 'REPORTED' THEN 'REPORTED'::statereport + WHEN state_mod_set_by IS NOT NULL THEN 'RESOLVED'::statereport + ELSE 'UNREPORTED'::statereport + END + """) - op.alter_column('submissions', 'state_mod', nullable=False) - op.alter_column('submissions', 'state_report', nullable=False) + op.alter_column('submissions', 'state_mod', nullable=False) + op.alter_column('submissions', 'state_report', nullable=False) - op.drop_column('submissions', 'is_banned') - op.drop_column('submissions', 'ban_reason') - op.drop_column('submissions', 'is_approved') - op.drop_column('submissions', 'filter_state') + op.drop_column('submissions', 'is_banned') + op.drop_column('submissions', 'ban_reason') + op.drop_column('submissions', 'is_approved') + op.drop_column('submissions', 'filter_state') def downgrade(): - op.add_column('comments', sa.Column('filter_state', sa.VARCHAR(length=40), autoincrement=False, nullable=True)) - op.add_column('comments', sa.Column('is_approved', sa.INTEGER(), autoincrement=False, nullable=True)) - op.add_column('comments', sa.Column('ban_reason', sa.VARCHAR(length=25), autoincrement=False, nullable=True)) - op.add_column('comments', sa.Column('is_banned', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) - op.create_foreign_key('comment_approver_fkey', 'comments', 'users', ['is_approved'], ['id']) - op.create_index('fki_comment_approver_fkey', 'comments', ['is_approved'], unique=False) + op.add_column('comments', sa.Column('filter_state', sa.VARCHAR(length=40), autoincrement=False, nullable=True)) + op.add_column('comments', sa.Column('is_approved', sa.INTEGER(), autoincrement=False, nullable=True)) + op.add_column('comments', sa.Column('ban_reason', sa.VARCHAR(length=25), autoincrement=False, nullable=True)) + op.add_column('comments', sa.Column('is_banned', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) + op.create_foreign_key('comment_approver_fkey', 'comments', 'users', ['is_approved'], ['id']) + op.create_index('fki_comment_approver_fkey', 'comments', ['is_approved'], unique=False) - op.execute(""" - UPDATE comments - SET is_banned = CASE - WHEN state_mod = 'REMOVED' THEN TRUE - ELSE FALSE - END - """) + op.execute(""" + UPDATE comments + SET is_banned = CASE + WHEN state_mod = 'REMOVED' THEN TRUE + ELSE FALSE + END + """) - op.execute(""" - UPDATE comments - SET is_approved = (SELECT id FROM users WHERE username = state_mod_set_by) - WHERE state_mod = 'VISIBLE' AND (state_report = 'RESOLVED' OR state_report = 'IGNORED') - """) + op.execute(""" + UPDATE comments + SET is_approved = (SELECT id FROM users WHERE username = state_mod_set_by) + WHERE state_mod = 'VISIBLE' AND (state_report = 'RESOLVED' OR state_report = 'IGNORED') + """) - op.execute(""" - UPDATE comments - SET ban_reason = CASE - WHEN state_mod = 'REMOVED' THEN state_mod_set_by - ELSE NULL - END - """) + op.execute(""" + UPDATE comments + SET ban_reason = CASE + WHEN state_mod = 'REMOVED' THEN state_mod_set_by + ELSE NULL + END + """) - op.execute(""" - UPDATE comments - SET filter_state = CASE - WHEN state_report = 'IGNORED' THEN 'IGNORED' - WHEN state_report = 'REPORTED' THEN 'REPORTED' - WHEN state_mod = 'FILTERED' THEN 'FILTERED' - ELSE NULL - END - """) + op.execute(""" + UPDATE comments + SET filter_state = CASE + WHEN state_report = 'IGNORED' THEN 'IGNORED' + WHEN state_report = 'REPORTED' THEN 'REPORTED' + WHEN state_mod = 'FILTERED' THEN 'FILTERED' + ELSE NULL + END + """) - op.alter_column('comments', sa.Column('filter_state', sa.VARCHAR(length=40), autoincrement=False, nullable=True)) - op.alter_column('comments', sa.Column('is_banned', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) + op.alter_column('comments', sa.Column('filter_state', sa.VARCHAR(length=40), autoincrement=False, nullable=True)) + op.alter_column('comments', sa.Column('is_banned', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) - op.drop_column('comments', 'state_report') - op.drop_column('comments', 'state_mod_set_by') - op.drop_column('comments', 'state_mod') - - op.add_column('submissions', sa.Column('filter_state', sa.VARCHAR(length=40), autoincrement=False, nullable=True)) - op.add_column('submissions', sa.Column('is_approved', sa.INTEGER(), autoincrement=False, nullable=True)) - op.add_column('submissions', sa.Column('ban_reason', sa.VARCHAR(length=25), autoincrement=False, nullable=True)) - op.add_column('submissions', sa.Column('is_banned', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) - op.create_foreign_key('submissions_approver_fkey', 'submissions', 'users', ['is_approved'], ['id']) - op.drop_index('submission_state_mod_idx', table_name='submissions') - op.drop_index('submission_new_sort_idx', table_name='submissions') - op.create_index('submission_new_sort_idx', 'submissions', ['is_banned', 'state_user_deleted_utc', 'created_utc', 'over_18'], unique=False) - op.drop_index('subimssion_binary_group_idx', table_name='submissions') - op.create_index('subimssion_binary_group_idx', 'submissions', ['is_banned', 'state_user_deleted_utc', 'over_18'], unique=False) - op.create_index('submission_isbanned_idx', 'submissions', ['is_banned'], unique=False) - op.create_index('fki_submissions_approver_fkey', 'submissions', ['is_approved'], unique=False) + op.drop_column('comments', 'state_report') + op.drop_column('comments', 'state_mod_set_by') + op.drop_column('comments', 'state_mod') + + op.add_column('submissions', sa.Column('filter_state', sa.VARCHAR(length=40), autoincrement=False, nullable=True)) + op.add_column('submissions', sa.Column('is_approved', sa.INTEGER(), autoincrement=False, nullable=True)) + op.add_column('submissions', sa.Column('ban_reason', sa.VARCHAR(length=25), autoincrement=False, nullable=True)) + op.add_column('submissions', sa.Column('is_banned', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) + op.create_foreign_key('submissions_approver_fkey', 'submissions', 'users', ['is_approved'], ['id']) + op.drop_index('submission_state_mod_idx', table_name='submissions') + op.drop_index('submission_new_sort_idx', table_name='submissions') + op.create_index('submission_new_sort_idx', 'submissions', ['is_banned', 'state_user_deleted_utc', 'created_utc', 'over_18'], unique=False) + op.drop_index('subimssion_binary_group_idx', table_name='submissions') + op.create_index('subimssion_binary_group_idx', 'submissions', ['is_banned', 'state_user_deleted_utc', 'over_18'], unique=False) + op.create_index('submission_isbanned_idx', 'submissions', ['is_banned'], unique=False) + op.create_index('fki_submissions_approver_fkey', 'submissions', ['is_approved'], unique=False) - op.execute(""" - UPDATE submissions - SET is_banned = CASE - WHEN state_mod = 'REMOVED' THEN TRUE - ELSE FALSE - END - """) + op.execute(""" + UPDATE submissions + SET is_banned = CASE + WHEN state_mod = 'REMOVED' THEN TRUE + ELSE FALSE + END + """) - op.execute(""" - UPDATE submissions - SET is_approved = (SELECT id FROM users WHERE username = state_mod_set_by) - WHERE state_mod = 'VISIBLE' AND (state_report = 'RESOLVED' OR state_report = 'IGNORED') - """) + op.execute(""" + UPDATE submissions + SET is_approved = (SELECT id FROM users WHERE username = state_mod_set_by) + WHERE state_mod = 'VISIBLE' AND (state_report = 'RESOLVED' OR state_report = 'IGNORED') + """) - op.execute(""" - UPDATE submissions - SET ban_reason = CASE - WHEN state_mod = 'REMOVED' THEN state_mod_set_by - ELSE NULL - END - """) + op.execute(""" + UPDATE submissions + SET ban_reason = CASE + WHEN state_mod = 'REMOVED' THEN state_mod_set_by + ELSE NULL + END + """) - op.execute(""" - UPDATE submissions - SET filter_state = CASE - WHEN state_report = 'IGNORED' THEN 'IGNORED' - WHEN state_report = 'REPORTED' THEN 'REPORTED' - WHEN state_mod = 'FILTERED' THEN 'FILTERED' - ELSE NULL - END - """) + op.execute(""" + UPDATE submissions + SET filter_state = CASE + WHEN state_report = 'IGNORED' THEN 'IGNORED' + WHEN state_report = 'REPORTED' THEN 'REPORTED' + WHEN state_mod = 'FILTERED' THEN 'FILTERED' + ELSE NULL + END + """) - op.alter_column('submissions', sa.Column('filter_state', sa.VARCHAR(length=40), autoincrement=False, nullable=True)) - op.alter_column('submissions', sa.Column('is_banned', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) + op.alter_column('submissions', sa.Column('filter_state', sa.VARCHAR(length=40), autoincrement=False, nullable=True)) + op.alter_column('submissions', sa.Column('is_banned', sa.BOOLEAN(), server_default=sa.text('false'), autoincrement=False, nullable=True)) - op.drop_column('submissions', 'state_report') - op.drop_column('submissions', 'state_mod_set_by') - op.drop_column('submissions', 'state_mod') + op.drop_column('submissions', 'state_report') + op.drop_column('submissions', 'state_mod_set_by') + op.drop_column('submissions', 'state_mod')