style: tabify for consistency

This commit is contained in:
justcool393 2023-07-14 22:32:24 -05:00
parent 1b590cefd7
commit e4f982328f
23 changed files with 587 additions and 587 deletions

View file

@ -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"}

View file

@ -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 ###

View file

@ -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 ###

View file

@ -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 ###

View file

@ -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 ###

View file

@ -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 ###

View file

@ -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 ###

View file

@ -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 ###

View file

@ -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 ###

View file

@ -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 ###

View file

@ -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 ###

View file

@ -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 ###

View file

@ -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))

View file

@ -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 ###

View file

@ -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 ###

View file

@ -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 ###

View file

@ -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)

View file

@ -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 ###

View file

@ -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 ###

View file

@ -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

View file

@ -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)

View file

@ -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'"""))
# 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'"""))

View file

@ -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')