From 85a47e643a255675df906d4b7092775377a58548 Mon Sep 17 00:00:00 2001 From: SvyatoslavArtymovych Date: Mon, 29 May 2023 09:36:19 +0300 Subject: [PATCH] black --- migrations/env.py | 22 +++--- .../versions/1dfa1f2c208f_comment_edited.py | 12 ++-- .../versions/2ec60080de3b_wallet_id_length.py | 28 ++++---- .../377fc0b7e4bb_user_is_activated.py | 24 +++---- .../4ce4bacc7c06_created_at_on_inter.py | 68 +++++++++++-------- .../versions/5df1fabbee7d_approved_fields.py | 31 +++++---- .../versions/7baa732e01c6_section_tags.py | 31 +++++---- ...8018384_remove_fields_from_section_and_.py | 26 ++++--- .../versions/a1345b416f81_user_avatar_img.py | 12 ++-- 9 files changed, 144 insertions(+), 110 deletions(-) diff --git a/migrations/env.py b/migrations/env.py index 68feded..0c6eddc 100644 --- a/migrations/env.py +++ b/migrations/env.py @@ -14,17 +14,17 @@ config = context.config # Interpret the config file for Python logging. # This line sets up loggers basically. fileConfig(config.config_file_name) -logger = logging.getLogger('alembic.env') +logger = logging.getLogger("alembic.env") # add your model's MetaData object here # for 'autogenerate' support # from myapp import mymodel # target_metadata = mymodel.Base.metadata config.set_main_option( - 'sqlalchemy.url', - str(current_app.extensions['migrate'].db.get_engine().url).replace( - '%', '%%')) -target_metadata = current_app.extensions['migrate'].db.metadata + "sqlalchemy.url", + str(current_app.extensions["migrate"].db.get_engine().url).replace("%", "%%"), +) +target_metadata = current_app.extensions["migrate"].db.metadata # other values from the config, defined by the needs of env.py, # can be acquired: @@ -45,9 +45,7 @@ def run_migrations_offline(): """ url = config.get_main_option("sqlalchemy.url") - context.configure( - url=url, target_metadata=target_metadata, literal_binds=True - ) + context.configure(url=url, target_metadata=target_metadata, literal_binds=True) with context.begin_transaction(): context.run_migrations() @@ -65,20 +63,20 @@ def run_migrations_online(): # when there are no changes to the schema # reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html def process_revision_directives(context, revision, directives): - if getattr(config.cmd_opts, 'autogenerate', False): + if getattr(config.cmd_opts, "autogenerate", False): script = directives[0] if script.upgrade_ops.is_empty(): directives[:] = [] - logger.info('No changes in schema detected.') + logger.info("No changes in schema detected.") - connectable = current_app.extensions['migrate'].db.get_engine() + connectable = current_app.extensions["migrate"].db.get_engine() with connectable.connect() as connection: context.configure( connection=connection, target_metadata=target_metadata, process_revision_directives=process_revision_directives, - **current_app.extensions['migrate'].configure_args + **current_app.extensions["migrate"].configure_args ) with context.begin_transaction(): diff --git a/migrations/versions/1dfa1f2c208f_comment_edited.py b/migrations/versions/1dfa1f2c208f_comment_edited.py index 9218ce6..2d90a24 100644 --- a/migrations/versions/1dfa1f2c208f_comment_edited.py +++ b/migrations/versions/1dfa1f2c208f_comment_edited.py @@ -10,23 +10,23 @@ import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = '1dfa1f2c208f' -down_revision = '2ec60080de3b' +revision = "1dfa1f2c208f" +down_revision = "2ec60080de3b" branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('comments', schema=None) as batch_op: - batch_op.add_column(sa.Column('edited', sa.Boolean(), nullable=True)) + with op.batch_alter_table("comments", schema=None) as batch_op: + batch_op.add_column(sa.Column("edited", sa.Boolean(), nullable=True)) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('comments', schema=None) as batch_op: - batch_op.drop_column('edited') + with op.batch_alter_table("comments", schema=None) as batch_op: + batch_op.drop_column("edited") # ### end Alembic commands ### diff --git a/migrations/versions/2ec60080de3b_wallet_id_length.py b/migrations/versions/2ec60080de3b_wallet_id_length.py index de553b5..b5c5fa3 100644 --- a/migrations/versions/2ec60080de3b_wallet_id_length.py +++ b/migrations/versions/2ec60080de3b_wallet_id_length.py @@ -10,29 +10,33 @@ import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = '2ec60080de3b' -down_revision = '4ce4bacc7c06' +revision = "2ec60080de3b" +down_revision = "4ce4bacc7c06" branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('users', schema=None) as batch_op: - batch_op.alter_column('wallet_id', - existing_type=sa.VARCHAR(length=256), - type_=sa.String(length=64), - existing_nullable=True) + with op.batch_alter_table("users", schema=None) as batch_op: + batch_op.alter_column( + "wallet_id", + existing_type=sa.VARCHAR(length=256), + type_=sa.String(length=64), + existing_nullable=True, + ) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('users', schema=None) as batch_op: - batch_op.alter_column('wallet_id', - existing_type=sa.String(length=64), - type_=sa.VARCHAR(length=256), - existing_nullable=True) + with op.batch_alter_table("users", schema=None) as batch_op: + batch_op.alter_column( + "wallet_id", + existing_type=sa.String(length=64), + type_=sa.VARCHAR(length=256), + existing_nullable=True, + ) # ### end Alembic commands ### diff --git a/migrations/versions/377fc0b7e4bb_user_is_activated.py b/migrations/versions/377fc0b7e4bb_user_is_activated.py index 9741106..fd92745 100644 --- a/migrations/versions/377fc0b7e4bb_user_is_activated.py +++ b/migrations/versions/377fc0b7e4bb_user_is_activated.py @@ -10,29 +10,29 @@ import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = '377fc0b7e4bb' -down_revision = 'a1345b416f81' +revision = "377fc0b7e4bb" +down_revision = "a1345b416f81" branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('users', schema=None) as batch_op: - batch_op.add_column(sa.Column('is_activated', sa.Boolean(), nullable=True)) - batch_op.alter_column('username', - existing_type=sa.VARCHAR(length=60), - nullable=True) + with op.batch_alter_table("users", schema=None) as batch_op: + batch_op.add_column(sa.Column("is_activated", sa.Boolean(), nullable=True)) + batch_op.alter_column( + "username", existing_type=sa.VARCHAR(length=60), nullable=True + ) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('users', schema=None) as batch_op: - batch_op.alter_column('username', - existing_type=sa.VARCHAR(length=60), - nullable=False) - batch_op.drop_column('is_activated') + with op.batch_alter_table("users", schema=None) as batch_op: + batch_op.alter_column( + "username", existing_type=sa.VARCHAR(length=60), nullable=False + ) + batch_op.drop_column("is_activated") # ### end Alembic commands ### diff --git a/migrations/versions/4ce4bacc7c06_created_at_on_inter.py b/migrations/versions/4ce4bacc7c06_created_at_on_inter.py index fa4648d..538475b 100644 --- a/migrations/versions/4ce4bacc7c06_created_at_on_inter.py +++ b/migrations/versions/4ce4bacc7c06_created_at_on_inter.py @@ -10,45 +10,57 @@ import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = '4ce4bacc7c06' -down_revision = '377fc0b7e4bb' +revision = "4ce4bacc7c06" +down_revision = "377fc0b7e4bb" branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('users', schema=None) as batch_op: - batch_op.alter_column('username', - existing_type=sa.VARCHAR(length=60), - type_=sa.String(length=64), - existing_nullable=True) - batch_op.alter_column('password_hash', - existing_type=sa.VARCHAR(length=255), - type_=sa.String(length=256), - existing_nullable=True) - batch_op.alter_column('wallet_id', - existing_type=sa.VARCHAR(length=255), - type_=sa.String(length=256), - existing_nullable=True) + with op.batch_alter_table("users", schema=None) as batch_op: + batch_op.alter_column( + "username", + existing_type=sa.VARCHAR(length=60), + type_=sa.String(length=64), + existing_nullable=True, + ) + batch_op.alter_column( + "password_hash", + existing_type=sa.VARCHAR(length=255), + type_=sa.String(length=256), + existing_nullable=True, + ) + batch_op.alter_column( + "wallet_id", + existing_type=sa.VARCHAR(length=255), + type_=sa.String(length=256), + existing_nullable=True, + ) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('users', schema=None) as batch_op: - batch_op.alter_column('wallet_id', - existing_type=sa.String(length=256), - type_=sa.VARCHAR(length=255), - existing_nullable=True) - batch_op.alter_column('password_hash', - existing_type=sa.String(length=256), - type_=sa.VARCHAR(length=255), - existing_nullable=True) - batch_op.alter_column('username', - existing_type=sa.String(length=64), - type_=sa.VARCHAR(length=60), - existing_nullable=True) + with op.batch_alter_table("users", schema=None) as batch_op: + batch_op.alter_column( + "wallet_id", + existing_type=sa.String(length=256), + type_=sa.VARCHAR(length=255), + existing_nullable=True, + ) + batch_op.alter_column( + "password_hash", + existing_type=sa.String(length=256), + type_=sa.VARCHAR(length=255), + existing_nullable=True, + ) + batch_op.alter_column( + "username", + existing_type=sa.String(length=64), + type_=sa.VARCHAR(length=60), + existing_nullable=True, + ) # ### end Alembic commands ### diff --git a/migrations/versions/5df1fabbee7d_approved_fields.py b/migrations/versions/5df1fabbee7d_approved_fields.py index a280f31..a2f3997 100644 --- a/migrations/versions/5df1fabbee7d_approved_fields.py +++ b/migrations/versions/5df1fabbee7d_approved_fields.py @@ -10,31 +10,38 @@ import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = '5df1fabbee7d' -down_revision = '1dfa1f2c208f' +revision = "5df1fabbee7d" +down_revision = "1dfa1f2c208f" branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('comments', schema=None) as batch_op: - batch_op.add_column(sa.Column('approved', sa.Boolean(), nullable=True)) - batch_op.drop_column('included_with_interpretation') + with op.batch_alter_table("comments", schema=None) as batch_op: + batch_op.add_column(sa.Column("approved", sa.Boolean(), nullable=True)) + batch_op.drop_column("included_with_interpretation") - with op.batch_alter_table('interpretations', schema=None) as batch_op: - batch_op.add_column(sa.Column('approved', sa.Boolean(), nullable=True)) + with op.batch_alter_table("interpretations", schema=None) as batch_op: + batch_op.add_column(sa.Column("approved", sa.Boolean(), nullable=True)) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('interpretations', schema=None) as batch_op: - batch_op.drop_column('approved') + with op.batch_alter_table("interpretations", schema=None) as batch_op: + batch_op.drop_column("approved") - with op.batch_alter_table('comments', schema=None) as batch_op: - batch_op.add_column(sa.Column('included_with_interpretation', sa.BOOLEAN(), autoincrement=False, nullable=True)) - batch_op.drop_column('approved') + with op.batch_alter_table("comments", schema=None) as batch_op: + batch_op.add_column( + sa.Column( + "included_with_interpretation", + sa.BOOLEAN(), + autoincrement=False, + nullable=True, + ) + ) + batch_op.drop_column("approved") # ### end Alembic commands ### diff --git a/migrations/versions/7baa732e01c6_section_tags.py b/migrations/versions/7baa732e01c6_section_tags.py index bf04d99..6fc4f99 100644 --- a/migrations/versions/7baa732e01c6_section_tags.py +++ b/migrations/versions/7baa732e01c6_section_tags.py @@ -10,28 +10,35 @@ import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = '7baa732e01c6' -down_revision = '0961578f302a' +revision = "7baa732e01c6" +down_revision = "0961578f302a" branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.create_table('section_tags', - sa.Column('tag_id', sa.Integer(), nullable=True), - sa.Column('section_id', sa.Integer(), nullable=True), - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('is_deleted', sa.Boolean(), nullable=True), - sa.ForeignKeyConstraint(['section_id'], ['sections.id'], ), - sa.ForeignKeyConstraint(['tag_id'], ['tags.id'], ), - sa.PrimaryKeyConstraint('id') + op.create_table( + "section_tags", + sa.Column("tag_id", sa.Integer(), nullable=True), + sa.Column("section_id", sa.Integer(), nullable=True), + sa.Column("id", sa.Integer(), nullable=False), + sa.Column("created_at", sa.DateTime(), nullable=True), + sa.Column("is_deleted", sa.Boolean(), nullable=True), + sa.ForeignKeyConstraint( + ["section_id"], + ["sections.id"], + ), + sa.ForeignKeyConstraint( + ["tag_id"], + ["tags.id"], + ), + sa.PrimaryKeyConstraint("id"), ) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('section_tags') + op.drop_table("section_tags") # ### end Alembic commands ### diff --git a/migrations/versions/883298018384_remove_fields_from_section_and_.py b/migrations/versions/883298018384_remove_fields_from_section_and_.py index f5fc7fd..86f7924 100644 --- a/migrations/versions/883298018384_remove_fields_from_section_and_.py +++ b/migrations/versions/883298018384_remove_fields_from_section_and_.py @@ -10,29 +10,35 @@ import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = '883298018384' -down_revision = '5df1fabbee7d' +revision = "883298018384" +down_revision = "5df1fabbee7d" branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('interpretations', schema=None) as batch_op: - batch_op.drop_column('label') + with op.batch_alter_table("interpretations", schema=None) as batch_op: + batch_op.drop_column("label") - with op.batch_alter_table('sections', schema=None) as batch_op: - batch_op.drop_column('about') + with op.batch_alter_table("sections", schema=None) as batch_op: + batch_op.drop_column("about") # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('sections', schema=None) as batch_op: - batch_op.add_column(sa.Column('about', sa.TEXT(), autoincrement=False, nullable=True)) + with op.batch_alter_table("sections", schema=None) as batch_op: + batch_op.add_column( + sa.Column("about", sa.TEXT(), autoincrement=False, nullable=True) + ) - with op.batch_alter_table('interpretations', schema=None) as batch_op: - batch_op.add_column(sa.Column('label', sa.VARCHAR(length=256), autoincrement=False, nullable=False)) + with op.batch_alter_table("interpretations", schema=None) as batch_op: + batch_op.add_column( + sa.Column( + "label", sa.VARCHAR(length=256), autoincrement=False, nullable=False + ) + ) # ### end Alembic commands ### diff --git a/migrations/versions/a1345b416f81_user_avatar_img.py b/migrations/versions/a1345b416f81_user_avatar_img.py index a854c16..71b6ff3 100644 --- a/migrations/versions/a1345b416f81_user_avatar_img.py +++ b/migrations/versions/a1345b416f81_user_avatar_img.py @@ -10,23 +10,23 @@ import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = 'a1345b416f81' -down_revision = '067a10a531d7' +revision = "a1345b416f81" +down_revision = "067a10a531d7" branch_labels = None depends_on = None def upgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('users', schema=None) as batch_op: - batch_op.add_column(sa.Column('avatar_img', sa.Text(), nullable=True)) + with op.batch_alter_table("users", schema=None) as batch_op: + batch_op.add_column(sa.Column("avatar_img", sa.Text(), nullable=True)) # ### end Alembic commands ### def downgrade(): # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('users', schema=None) as batch_op: - batch_op.drop_column('avatar_img') + with op.batch_alter_table("users", schema=None) as batch_op: + batch_op.drop_column("avatar_img") # ### end Alembic commands ###