diff options
author | 2023-09-04 21:21:37 +0100 | |
---|---|---|
committer | 2023-09-04 21:21:37 +0100 | |
commit | c6829ab8134adceb2ed0bdaf71f1abfeef63286c (patch) | |
tree | 04848901819ede9c851bd07fea46bd709d91f7af /alembic | |
parent | Use `thread.created_at` to determine thread creation (diff) |
Subject Alembic files to the wrath of the linter
Diffstat (limited to 'alembic')
23 files changed, 328 insertions, 286 deletions
diff --git a/alembic/env.py b/alembic/env.py index 903d5ef..91aca63 100644 --- a/alembic/env.py +++ b/alembic/env.py @@ -1,15 +1,10 @@ +import asyncio from logging.config import fileConfig +from sqlalchemy import Connection, pool from sqlalchemy.ext.asyncio import async_engine_from_config -from sqlalchemy import pool - -import asyncio from alembic import context - -import sys -sys.path.append(".") - from metricity.database import build_db_uri from metricity.models import Base @@ -23,29 +18,23 @@ fileConfig(config.config_file_name) # add your model's MetaData object here # for 'autogenerate' support -# from myapp import mymodel -# target_metadata = mymodel.Base.metadata target_metadata = Base.metadata # other values from the config, defined by the needs of env.py, # can be acquired: -# my_important_option = config.get_main_option("my_important_option") # ... etc. -config.set_main_option('sqlalchemy.url', build_db_uri()) +config.set_main_option("sqlalchemy.url", build_db_uri()) -def do_run_migrations(connection): +def do_run_migrations(connection: Connection) -> None: + """Run migrations.""" context.configure(connection=connection, target_metadata=target_metadata) with context.begin_transaction(): context.run_migrations() -async def run_async_migrations(): - """In this scenario we need to create an Engine - and associate a connection with the context. - - """ - +async def run_async_migrations() -> None: + """Run migrations asynchronously using the asyncpg driver.""" connectable = async_engine_from_config( config.get_section(config.config_ini_section), prefix="sqlalchemy.", @@ -57,8 +46,9 @@ async def run_async_migrations(): await connectable.dispose() -def run_migrations_offline(): - """Run migrations in 'offline' mode. +def run_migrations_offline() -> None: + """ + Run migrations in 'offline' mode. This configures the context with just a URL and not an Engine, though an Engine is acceptable @@ -81,9 +71,8 @@ def run_migrations_offline(): context.run_migrations() -def run_migrations_online(): +def run_migrations_online() -> None: """Run migrations in 'online' mode.""" - asyncio.run(run_async_migrations()) diff --git a/alembic/script.py.mako b/alembic/script.py.mako index 2c01563..2c87742 100644 --- a/alembic/script.py.mako +++ b/alembic/script.py.mako @@ -16,9 +16,11 @@ branch_labels = ${repr(branch_labels)} depends_on = ${repr(depends_on)} -def upgrade(): - ${upgrades if upgrades else "pass"} +def upgrade() -> None: + """Apply the current migration.""" + ${upgrades} -def downgrade(): - ${downgrades if downgrades else "pass"} +def downgrade() -> None: + """Revert the current migration.""" + ${downgrades} diff --git a/alembic/versions/03655ce2097b_new_not_null_constraints_on_messages_.py b/alembic/versions/03655ce2097b_new_not_null_constraints_on_messages_.py index 66cb029..8ad0473 100644 --- a/alembic/versions/03655ce2097b_new_not_null_constraints_on_messages_.py +++ b/alembic/versions/03655ce2097b_new_not_null_constraints_on_messages_.py @@ -17,7 +17,8 @@ branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### op.alter_column("messages", "channel_id", existing_type=sa.VARCHAR(), @@ -40,7 +41,8 @@ def upgrade(): # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### op.alter_column("users", "pending", existing_type=sa.BOOLEAN(), diff --git a/alembic/versions/25f3b8fb9961_add_pending_column_to_user.py b/alembic/versions/25f3b8fb9961_add_pending_column_to_user.py index 5b3b6f6..6a2e4c5 100644 --- a/alembic/versions/25f3b8fb9961_add_pending_column_to_user.py +++ b/alembic/versions/25f3b8fb9961_add_pending_column_to_user.py @@ -1,28 +1,31 @@ -"""add pending column to user +""" +add pending column to user. Revision ID: 25f3b8fb9961 Revises: a259ab5efcec Create Date: 2020-12-21 17:42:04.566930 """ -from alembic import op import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = '25f3b8fb9961' -down_revision = 'a259ab5efcec' +revision = "25f3b8fb9961" +down_revision = "a259ab5efcec" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.add_column('users', sa.Column('pending', sa.Boolean(), nullable=True)) + op.add_column("users", sa.Column("pending", sa.Boolean(), nullable=True)) # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('users', 'pending') + op.drop_column("users", "pending") # ### end Alembic commands ### diff --git a/alembic/versions/2743389eb63e_add_all_tables_with_string_keys.py b/alembic/versions/2743389eb63e_add_all_tables_with_string_keys.py index 10bb0d2..9122979 100644 --- a/alembic/versions/2743389eb63e_add_all_tables_with_string_keys.py +++ b/alembic/versions/2743389eb63e_add_all_tables_with_string_keys.py @@ -1,63 +1,66 @@ -"""add all tables with string keys +""" +add all tables with string keys. Revision ID: 2743389eb63e Revises: 2e383ecae493 Create Date: 2020-08-25 16:35:38.833315 """ -from alembic import op import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = '2743389eb63e' -down_revision = '2e383ecae493' +revision = "2743389eb63e" +down_revision = "2e383ecae493" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.create_table('categories', - sa.Column('id', sa.String(), nullable=False), - sa.Column('name', sa.String(), nullable=False), - sa.PrimaryKeyConstraint('id') + op.create_table("categories", + sa.Column("id", sa.String(), nullable=False), + sa.Column("name", sa.String(), nullable=False), + sa.PrimaryKeyConstraint("id"), ) - op.create_table('users', - sa.Column('id', sa.String(), nullable=False), - sa.Column('name', sa.String(), nullable=False), - sa.Column('avatar_hash', sa.String(), nullable=True), - sa.Column('joined_at', sa.DateTime(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('is_staff', sa.Boolean(), nullable=False), - sa.Column('opt_out', sa.Boolean(), nullable=True), - sa.Column('bot', sa.Boolean(), nullable=True), - sa.PrimaryKeyConstraint('id') + op.create_table("users", + sa.Column("id", sa.String(), nullable=False), + sa.Column("name", sa.String(), nullable=False), + sa.Column("avatar_hash", sa.String(), nullable=True), + sa.Column("joined_at", sa.DateTime(), nullable=False), + sa.Column("created_at", sa.DateTime(), nullable=False), + sa.Column("is_staff", sa.Boolean(), nullable=False), + sa.Column("opt_out", sa.Boolean(), nullable=True), + sa.Column("bot", sa.Boolean(), nullable=True), + sa.PrimaryKeyConstraint("id"), ) - op.create_table('channels', - sa.Column('id', sa.String(), nullable=False), - sa.Column('name', sa.String(), nullable=False), - sa.Column('category_id', sa.String(), nullable=True), - sa.Column('is_staff', sa.Boolean(), nullable=False), - sa.ForeignKeyConstraint(['category_id'], ['categories.id'], ), - sa.PrimaryKeyConstraint('id') + op.create_table("channels", + sa.Column("id", sa.String(), nullable=False), + sa.Column("name", sa.String(), nullable=False), + sa.Column("category_id", sa.String(), nullable=True), + sa.Column("is_staff", sa.Boolean(), nullable=False), + sa.ForeignKeyConstraint(["category_id"], ["categories.id"] ), + sa.PrimaryKeyConstraint("id"), ) - op.create_table('messages', - sa.Column('id', sa.String(), nullable=False), - sa.Column('channel_id', sa.String(), nullable=True), - sa.Column('author_id', sa.String(), nullable=True), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['author_id'], ['users.id'], ondelete='CASCADE'), - sa.ForeignKeyConstraint(['channel_id'], ['channels.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id') + op.create_table("messages", + sa.Column("id", sa.String(), nullable=False), + sa.Column("channel_id", sa.String(), nullable=True), + sa.Column("author_id", sa.String(), nullable=True), + sa.Column("created_at", sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(["author_id"], ["users.id"], ondelete="CASCADE"), + sa.ForeignKeyConstraint(["channel_id"], ["channels.id"], ondelete="CASCADE"), + sa.PrimaryKeyConstraint("id"), ) # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('messages') - op.drop_table('channels') - op.drop_table('users') - op.drop_table('categories') + op.drop_table("messages") + op.drop_table("channels") + op.drop_table("users") + op.drop_table("categories") # ### end Alembic commands ### diff --git a/alembic/versions/2e383ecae493_remove_all_tables_for_conversion_to_.py b/alembic/versions/2e383ecae493_remove_all_tables_for_conversion_to_.py index 33f3673..f16a1a5 100644 --- a/alembic/versions/2e383ecae493_remove_all_tables_for_conversion_to_.py +++ b/alembic/versions/2e383ecae493_remove_all_tables_for_conversion_to_.py @@ -1,27 +1,28 @@ -"""remove all tables for conversion to string keys +""" +remove all tables for conversion to string keys. Revision ID: 2e383ecae493 Revises: b1fdfe71fcb7 Create Date: 2020-08-25 16:31:05.025135 """ -from alembic import op -import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = '2e383ecae493' -down_revision = 'b1fdfe71fcb7' +revision = "2e383ecae493" +down_revision = "b1fdfe71fcb7" branch_labels = None depends_on = None -def upgrade(): - op.drop_table('messages') - op.drop_table('users') - op.drop_table('channels') - op.drop_table('categories') +def upgrade() -> None: + """Apply the current migration.""" + op.drop_table("messages") + op.drop_table("users") + op.drop_table("channels") + op.drop_table("categories") -def downgrade(): - pass +def downgrade() -> None: + """Revert the current migration.""" diff --git a/alembic/versions/2faa292e5818_add_indexes_on_message_table.py b/alembic/versions/2faa292e5818_add_indexes_on_message_table.py index 0cb7400..04f424c 100644 --- a/alembic/versions/2faa292e5818_add_indexes_on_message_table.py +++ b/alembic/versions/2faa292e5818_add_indexes_on_message_table.py @@ -1,30 +1,32 @@ -"""Add indexes on message table +""" +Add indexes on message table. Revision ID: 2faa292e5818 Revises: d052a6b677e6 Create Date: 2020-10-27 02:52:23.791738 """ -from alembic import op -import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = '2faa292e5818' -down_revision = 'd052a6b677e6' +revision = "2faa292e5818" +down_revision = "d052a6b677e6" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.create_index(op.f('ix_messages_author_id'), 'messages', ['author_id'], unique=False) - op.create_index(op.f('ix_messages_channel_id'), 'messages', ['channel_id'], unique=False) + op.create_index(op.f("ix_messages_author_id"), "messages", ["author_id"], unique=False) + op.create_index(op.f("ix_messages_channel_id"), "messages", ["channel_id"], unique=False) # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_index(op.f('ix_messages_channel_id'), table_name='messages') - op.drop_index(op.f('ix_messages_author_id'), table_name='messages') + op.drop_index(op.f("ix_messages_channel_id"), table_name="messages") + op.drop_index(op.f("ix_messages_author_id"), table_name="messages") # ### end Alembic commands ### diff --git a/alembic/versions/38085c8f1099_enable_cascade_deletion_for_messages.py b/alembic/versions/38085c8f1099_enable_cascade_deletion_for_messages.py index 522d96a..db404bb 100644 --- a/alembic/versions/38085c8f1099_enable_cascade_deletion_for_messages.py +++ b/alembic/versions/38085c8f1099_enable_cascade_deletion_for_messages.py @@ -1,34 +1,36 @@ -"""enable cascade deletion for messages +""" +enable cascade deletion for messages. Revision ID: 38085c8f1099 Revises: abc065ff2fb3 Create Date: 2020-08-25 13:00:21.629836 """ -from alembic import op -import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = '38085c8f1099' -down_revision = 'abc065ff2fb3' +revision = "38085c8f1099" +down_revision = "abc065ff2fb3" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint('messages_author_id_fkey', 'messages', type_='foreignkey') - op.drop_constraint('messages_channel_id_fkey', 'messages', type_='foreignkey') - op.create_foreign_key(None, 'messages', 'users', ['author_id'], ['id'], ondelete='CASCADE') - op.create_foreign_key(None, 'messages', 'channels', ['channel_id'], ['id'], ondelete='CASCADE') + op.drop_constraint("messages_author_id_fkey", "messages", type_="foreignkey") + op.drop_constraint("messages_channel_id_fkey", "messages", type_="foreignkey") + op.create_foreign_key(None, "messages", "users", ["author_id"], ["id"], ondelete="CASCADE") + op.create_foreign_key(None, "messages", "channels", ["channel_id"], ["id"], ondelete="CASCADE") # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint(None, 'messages', type_='foreignkey') - op.drop_constraint(None, 'messages', type_='foreignkey') - op.create_foreign_key('messages_channel_id_fkey', 'messages', 'channels', ['channel_id'], ['id']) - op.create_foreign_key('messages_author_id_fkey', 'messages', 'users', ['author_id'], ['id']) + op.drop_constraint(None, "messages", type_="foreignkey") + op.drop_constraint(None, "messages", type_="foreignkey") + op.create_foreign_key("messages_channel_id_fkey", "messages", "channels", ["channel_id"], ["id"]) + op.create_foreign_key("messages_author_id_fkey", "messages", "users", ["author_id"], ["id"]) # ### end Alembic commands ### diff --git a/alembic/versions/408aac572bff_cascade_delete_channels_on_category_.py b/alembic/versions/408aac572bff_cascade_delete_channels_on_category_.py index 4afbba7..e962309 100644 --- a/alembic/versions/408aac572bff_cascade_delete_channels_on_category_.py +++ b/alembic/versions/408aac572bff_cascade_delete_channels_on_category_.py @@ -1,30 +1,32 @@ -"""cascade delete channels on category deletion +""" +cascade delete channels on category deletion. Revision ID: 408aac572bff Revises: 25f3b8fb9961 Create Date: 2021-03-04 01:11:32.519071 """ -from alembic import op -import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = '408aac572bff' -down_revision = '25f3b8fb9961' +revision = "408aac572bff" +down_revision = "25f3b8fb9961" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint('channels_category_id_fkey', 'channels', type_='foreignkey') - op.create_foreign_key(None, 'channels', 'categories', ['category_id'], ['id'], ondelete='CASCADE') + op.drop_constraint("channels_category_id_fkey", "channels", type_="foreignkey") + op.create_foreign_key(None, "channels", "categories", ["category_id"], ["id"], ondelete="CASCADE") # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint(None, 'channels', type_='foreignkey') - op.create_foreign_key('channels_category_id_fkey', 'channels', 'categories', ['category_id'], ['id']) + op.drop_constraint(None, "channels", type_="foreignkey") + op.create_foreign_key("channels_category_id_fkey", "channels", "categories", ["category_id"], ["id"]) # ### end Alembic commands ### diff --git a/alembic/versions/451f61f7f7cb_add_is_verified_column.py b/alembic/versions/451f61f7f7cb_add_is_verified_column.py index 2c03698..bed4a0c 100644 --- a/alembic/versions/451f61f7f7cb_add_is_verified_column.py +++ b/alembic/versions/451f61f7f7cb_add_is_verified_column.py @@ -1,28 +1,31 @@ -"""Add is_verified column +""" +Add is_verified column. Revision ID: 451f61f7f7cb Revises: 5683123ff89a Create Date: 2020-08-29 17:19:32.029529 """ -from alembic import op import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = '451f61f7f7cb' -down_revision = '5683123ff89a' +revision = "451f61f7f7cb" +down_revision = "5683123ff89a" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.add_column('users', sa.Column('is_verified', sa.Boolean(), nullable=True)) + op.add_column("users", sa.Column("is_verified", sa.Boolean(), nullable=True)) # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('users', 'is_verified') + op.drop_column("users", "is_verified") # ### end Alembic commands ### diff --git a/alembic/versions/45973dacf7da_add_public_flags_column.py b/alembic/versions/45973dacf7da_add_public_flags_column.py index 06c7338..e5fa5a4 100644 --- a/alembic/versions/45973dacf7da_add_public_flags_column.py +++ b/alembic/versions/45973dacf7da_add_public_flags_column.py @@ -1,28 +1,31 @@ -"""Add public flags column +""" +Add public flags column. Revision ID: 45973dacf7da Revises: 451f61f7f7cb Create Date: 2020-09-02 10:38:18.142271 """ -from alembic import op import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = '45973dacf7da' -down_revision = '451f61f7f7cb' +revision = "45973dacf7da" +down_revision = "451f61f7f7cb" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.add_column('users', sa.Column('public_flags', sa.JSON(), nullable=True)) + op.add_column("users", sa.Column("public_flags", sa.JSON(), nullable=True)) # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('users', 'public_flags') + op.drop_column("users", "public_flags") # ### end Alembic commands ### diff --git a/alembic/versions/4d293b37634c_initial_migration.py b/alembic/versions/4d293b37634c_initial_migration.py index fa5e21b..e78a0b4 100644 --- a/alembic/versions/4d293b37634c_initial_migration.py +++ b/alembic/versions/4d293b37634c_initial_migration.py @@ -1,28 +1,25 @@ -"""initial migration +""" +initial migration. Revision ID: 4d293b37634c Revises: Create Date: 2020-08-25 03:09:13.565389 """ -from alembic import op -import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = '4d293b37634c' +revision = "4d293b37634c" down_revision = None branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - pass # ### end Alembic commands ### -def downgrade(): - # ### commands auto generated by Alembic - please adjust! ### - pass - # ### end Alembic commands ### +def downgrade() -> None: + """Revert the current migration.""" diff --git a/alembic/versions/563a15b2a76e_add_support_for_threads.py b/alembic/versions/563a15b2a76e_add_support_for_threads.py index 6f21e92..e8b39a6 100644 --- a/alembic/versions/563a15b2a76e_add_support_for_threads.py +++ b/alembic/versions/563a15b2a76e_add_support_for_threads.py @@ -1,47 +1,50 @@ -"""Add support for threads +""" +Add support for threads. Revision ID: 563a15b2a76e Revises: d6c9452c3940 Create Date: 2021-10-31 14:46:49.926646 """ -from alembic import op import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = '563a15b2a76e' -down_revision = 'd6c9452c3940' +revision = "563a15b2a76e" +down_revision = "d6c9452c3940" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### op.create_table( - 'threads', - sa.Column('id', sa.String(), nullable=False), - sa.Column('parent_channel_id', sa.String(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.Column('name', sa.String(), nullable=False), - sa.Column('archived', sa.Boolean(), nullable=False), - sa.Column('auto_archive_duration', sa.Integer(), nullable=False), - sa.Column('locked', sa.Boolean(), nullable=False), - sa.Column('type', sa.String(), nullable=False), - sa.ForeignKeyConstraint(['parent_channel_id'], ['channels.id'], ondelete='CASCADE'), - sa.PrimaryKeyConstraint('id') + "threads", + sa.Column("id", sa.String(), nullable=False), + sa.Column("parent_channel_id", sa.String(), nullable=False), + sa.Column("created_at", sa.DateTime(), nullable=True), + sa.Column("name", sa.String(), nullable=False), + sa.Column("archived", sa.Boolean(), nullable=False), + sa.Column("auto_archive_duration", sa.Integer(), nullable=False), + sa.Column("locked", sa.Boolean(), nullable=False), + sa.Column("type", sa.String(), nullable=False), + sa.ForeignKeyConstraint(["parent_channel_id"], ["channels.id"], ondelete="CASCADE"), + sa.PrimaryKeyConstraint("id"), ) - op.add_column('messages', sa.Column('thread_id', sa.String(), nullable=True)) - op.create_index(op.f('ix_messages_thread_id'), 'messages', ['thread_id'], unique=False) - op.create_index(op.f('ix_threads_type'), 'threads', ['type'], unique=False) - op.create_foreign_key(None, 'messages', 'threads', ['thread_id'], ['id'], ondelete='CASCADE') + op.add_column("messages", sa.Column("thread_id", sa.String(), nullable=True)) + op.create_index(op.f("ix_messages_thread_id"), "messages", ["thread_id"], unique=False) + op.create_index(op.f("ix_threads_type"), "threads", ["type"], unique=False) + op.create_foreign_key(None, "messages", "threads", ["thread_id"], ["id"], ondelete="CASCADE") # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint(None, 'messages', type_='foreignkey') - op.drop_index(op.f('ix_messages_thread_id'), table_name='messages') - op.drop_column('messages', 'thread_id') - op.drop_table('threads') + op.drop_constraint(None, "messages", type_="foreignkey") + op.drop_index(op.f("ix_messages_thread_id"), table_name="messages") + op.drop_column("messages", "thread_id") + op.drop_table("threads") # ### end Alembic commands ### diff --git a/alembic/versions/5683123ff89a_add_in_guild_column.py b/alembic/versions/5683123ff89a_add_in_guild_column.py index 12d67a1..9641b18 100644 --- a/alembic/versions/5683123ff89a_add_in_guild_column.py +++ b/alembic/versions/5683123ff89a_add_in_guild_column.py @@ -1,28 +1,31 @@ -"""add in_guild column +""" +add in_guild column. Revision ID: 5683123ff89a Revises: 2743389eb63e Create Date: 2020-08-25 19:57:41.958297 """ -from alembic import op import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = '5683123ff89a' -down_revision = '2743389eb63e' +revision = "5683123ff89a" +down_revision = "2743389eb63e" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.add_column('users', sa.Column('in_guild', sa.Boolean(), nullable=True)) + op.add_column("users", sa.Column("in_guild", sa.Boolean(), nullable=True)) # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('users', 'in_guild') + op.drop_column("users", "in_guild") # ### end Alembic commands ### diff --git a/alembic/versions/6b52b1e7680b_add_channel_categories.py b/alembic/versions/6b52b1e7680b_add_channel_categories.py index bdbcde1..bde8a6d 100644 --- a/alembic/versions/6b52b1e7680b_add_channel_categories.py +++ b/alembic/versions/6b52b1e7680b_add_channel_categories.py @@ -1,34 +1,37 @@ -"""add channel categories +""" +add channel categories. Revision ID: 6b52b1e7680b Revises: d42a9cc66591 Create Date: 2020-08-25 05:10:43.945126 """ -from alembic import op import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = '6b52b1e7680b' -down_revision = 'd42a9cc66591' +revision = "6b52b1e7680b" +down_revision = "d42a9cc66591" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.create_table('categories', - sa.Column('id', sa.BigInteger(), nullable=False), - sa.Column('name', sa.String(), nullable=False), - sa.PrimaryKeyConstraint('id') + op.create_table("categories", + sa.Column("id", sa.BigInteger(), nullable=False), + sa.Column("name", sa.String(), nullable=False), + sa.PrimaryKeyConstraint("id"), ) - op.add_column('channels', sa.Column('category_id', sa.BigInteger(), nullable=True)) + op.add_column("channels", sa.Column("category_id", sa.BigInteger(), nullable=True)) # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('channels', 'category_id') - op.drop_table('categories') + op.drop_column("channels", "category_id") + op.drop_table("categories") # ### end Alembic commands ### diff --git a/alembic/versions/911049796159_remove_opt_out_column.py b/alembic/versions/911049796159_remove_opt_out_column.py index 6ba71ba..812c80b 100644 --- a/alembic/versions/911049796159_remove_opt_out_column.py +++ b/alembic/versions/911049796159_remove_opt_out_column.py @@ -1,28 +1,31 @@ -"""Remove opt_out column +""" +Remove opt_out column. Revision ID: 911049796159 Revises: 408aac572bff Create Date: 2021-04-09 05:09:28.565384 """ -from alembic import op import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = '911049796159' -down_revision = '408aac572bff' +revision = "911049796159" +down_revision = "408aac572bff" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('users', 'opt_out') + op.drop_column("users", "opt_out") # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.add_column('users', sa.Column('opt_out', sa.BOOLEAN(), autoincrement=False, nullable=True)) + op.add_column("users", sa.Column("opt_out", sa.BOOLEAN(), autoincrement=False, nullable=True)) # ### end Alembic commands ### diff --git a/alembic/versions/a259ab5efcec_remove_verified_columns.py b/alembic/versions/a259ab5efcec_remove_verified_columns.py index 099e158..5b59d53 100644 --- a/alembic/versions/a259ab5efcec_remove_verified_columns.py +++ b/alembic/versions/a259ab5efcec_remove_verified_columns.py @@ -1,30 +1,34 @@ -"""remove verified columns +""" +remove verified columns. Revision ID: a259ab5efcec Revises: 2faa292e5818 Create Date: 2020-12-19 22:44:27.897133 """ -from alembic import op import sqlalchemy as sa from sqlalchemy.dialects import postgresql +from alembic import op + # revision identifiers, used by Alembic. -revision = 'a259ab5efcec' -down_revision = '2faa292e5818' +revision = "a259ab5efcec" +down_revision = "2faa292e5818" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('users', 'is_verified') - op.drop_column('users', 'verified_at') + op.drop_column("users", "is_verified") + op.drop_column("users", "verified_at") # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.add_column('users', sa.Column('verified_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=True)) - op.add_column('users', sa.Column('is_verified', sa.BOOLEAN(), autoincrement=False, nullable=True)) + op.add_column("users", sa.Column("verified_at", postgresql.TIMESTAMP(), autoincrement=False, nullable=True)) + op.add_column("users", sa.Column("is_verified", sa.BOOLEAN(), autoincrement=False, nullable=True)) # ### end Alembic commands ### diff --git a/alembic/versions/aa3517f1b1bd_add_verified_at_column.py b/alembic/versions/aa3517f1b1bd_add_verified_at_column.py index f7ea257..8c36e04 100644 --- a/alembic/versions/aa3517f1b1bd_add_verified_at_column.py +++ b/alembic/versions/aa3517f1b1bd_add_verified_at_column.py @@ -1,28 +1,31 @@ -"""Add verified_at column +""" +Add verified_at column. Revision ID: aa3517f1b1bd Revises: 45973dacf7da Create Date: 2020-09-12 02:34:11.722267 """ -from alembic import op import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = 'aa3517f1b1bd' -down_revision = '45973dacf7da' +revision = "aa3517f1b1bd" +down_revision = "45973dacf7da" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.add_column('users', sa.Column('verified_at', sa.DateTime(), nullable=True)) + op.add_column("users", sa.Column("verified_at", sa.DateTime(), nullable=True)) # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('users', 'verified_at') + op.drop_column("users", "verified_at") # ### end Alembic commands ### diff --git a/alembic/versions/abc065ff2fb3_add_bot_column_to_user_table.py b/alembic/versions/abc065ff2fb3_add_bot_column_to_user_table.py index 9c53999..0fd0e36 100644 --- a/alembic/versions/abc065ff2fb3_add_bot_column_to_user_table.py +++ b/alembic/versions/abc065ff2fb3_add_bot_column_to_user_table.py @@ -1,28 +1,31 @@ -"""add bot column to user table +""" +add bot column to user table. Revision ID: abc065ff2fb3 Revises: 6b52b1e7680b Create Date: 2020-08-25 05:24:01.730596 """ -from alembic import op import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = 'abc065ff2fb3' -down_revision = '6b52b1e7680b' +revision = "abc065ff2fb3" +down_revision = "6b52b1e7680b" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.add_column('users', sa.Column('bot', sa.Boolean(), nullable=True)) + op.add_column("users", sa.Column("bot", sa.Boolean(), nullable=True)) # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('users', 'bot') + op.drop_column("users", "bot") # ### end Alembic commands ### diff --git a/alembic/versions/b1fdfe71fcb7_channel_category_foreign_key.py b/alembic/versions/b1fdfe71fcb7_channel_category_foreign_key.py index 329924b..8d7745a 100644 --- a/alembic/versions/b1fdfe71fcb7_channel_category_foreign_key.py +++ b/alembic/versions/b1fdfe71fcb7_channel_category_foreign_key.py @@ -1,28 +1,30 @@ -"""channel category foreign key +""" +channel category foreign key. Revision ID: b1fdfe71fcb7 Revises: 38085c8f1099 Create Date: 2020-08-25 15:00:38.666504 """ -from alembic import op -import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = 'b1fdfe71fcb7' -down_revision = '38085c8f1099' +revision = "b1fdfe71fcb7" +down_revision = "38085c8f1099" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.create_foreign_key(None, 'channels', 'categories', ['category_id'], ['id']) + op.create_foreign_key(None, "channels", "categories", ["category_id"], ["id"]) # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_constraint(None, 'channels', type_='foreignkey') + op.drop_constraint(None, "channels", type_="foreignkey") # ### end Alembic commands ### diff --git a/alembic/versions/d052a6b677e6_add_is_deleted_to_message.py b/alembic/versions/d052a6b677e6_add_is_deleted_to_message.py index 8354a3e..3a8a952 100644 --- a/alembic/versions/d052a6b677e6_add_is_deleted_to_message.py +++ b/alembic/versions/d052a6b677e6_add_is_deleted_to_message.py @@ -1,28 +1,31 @@ -"""add is_deleted to Message +""" +add is_deleted to Message. Revision ID: d052a6b677e6 Revises: aa3517f1b1bd Create Date: 2020-10-18 19:20:20.862476 """ -from alembic import op import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = 'd052a6b677e6' -down_revision = 'aa3517f1b1bd' +revision = "d052a6b677e6" +down_revision = "aa3517f1b1bd" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.add_column('messages', sa.Column('is_deleted', sa.Boolean(), nullable=True)) + op.add_column("messages", sa.Column("is_deleted", sa.Boolean(), nullable=True)) # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('messages', 'is_deleted') + op.drop_column("messages", "is_deleted") # ### end Alembic commands ### diff --git a/alembic/versions/d42a9cc66591_add_channels_users_and_messages_table.py b/alembic/versions/d42a9cc66591_add_channels_users_and_messages_table.py index 0ed3728..b3c1a4d 100644 --- a/alembic/versions/d42a9cc66591_add_channels_users_and_messages_table.py +++ b/alembic/versions/d42a9cc66591_add_channels_users_and_messages_table.py @@ -1,54 +1,57 @@ -"""add channels, users and messages table +""" +add channels, users and messages table. Revision ID: d42a9cc66591 Revises: 4d293b37634c Create Date: 2020-08-25 03:10:21.282787 """ -from alembic import op import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = 'd42a9cc66591' -down_revision = '4d293b37634c' +revision = "d42a9cc66591" +down_revision = "4d293b37634c" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.create_table('channels', - sa.Column('id', sa.BigInteger(), nullable=False), - sa.Column('name', sa.String(), nullable=False), - sa.Column('is_staff', sa.Boolean(), nullable=False), - sa.PrimaryKeyConstraint('id') + op.create_table("channels", + sa.Column("id", sa.BigInteger(), nullable=False), + sa.Column("name", sa.String(), nullable=False), + sa.Column("is_staff", sa.Boolean(), nullable=False), + sa.PrimaryKeyConstraint("id"), ) - op.create_table('users', - sa.Column('id', sa.BigInteger(), nullable=False), - sa.Column('name', sa.String(), nullable=False), - sa.Column('avatar_hash', sa.String(), nullable=True), - sa.Column('joined_at', sa.DateTime(), nullable=False), - sa.Column('created_at', sa.DateTime(), nullable=False), - sa.Column('is_staff', sa.Boolean(), nullable=False), - sa.Column('opt_out', sa.Boolean(), nullable=True), - sa.PrimaryKeyConstraint('id') + op.create_table("users", + sa.Column("id", sa.BigInteger(), nullable=False), + sa.Column("name", sa.String(), nullable=False), + sa.Column("avatar_hash", sa.String(), nullable=True), + sa.Column("joined_at", sa.DateTime(), nullable=False), + sa.Column("created_at", sa.DateTime(), nullable=False), + sa.Column("is_staff", sa.Boolean(), nullable=False), + sa.Column("opt_out", sa.Boolean(), nullable=True), + sa.PrimaryKeyConstraint("id"), ) - op.create_table('messages', - sa.Column('id', sa.BigInteger(), nullable=False), - sa.Column('channel_id', sa.BigInteger(), nullable=True), - sa.Column('author_id', sa.BigInteger(), nullable=True), - sa.Column('created_at', sa.DateTime(), nullable=True), - sa.ForeignKeyConstraint(['author_id'], ['users.id'], ), - sa.ForeignKeyConstraint(['channel_id'], ['channels.id'], ), - sa.PrimaryKeyConstraint('id') + op.create_table("messages", + sa.Column("id", sa.BigInteger(), nullable=False), + sa.Column("channel_id", sa.BigInteger(), nullable=True), + sa.Column("author_id", sa.BigInteger(), nullable=True), + sa.Column("created_at", sa.DateTime(), nullable=True), + sa.ForeignKeyConstraint(["author_id"], ["users.id"] ), + sa.ForeignKeyConstraint(["channel_id"], ["channels.id"] ), + sa.PrimaryKeyConstraint("id"), ) # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_table('messages') - op.drop_table('users') - op.drop_table('channels') + op.drop_table("messages") + op.drop_table("users") + op.drop_table("channels") # ### end Alembic commands ### diff --git a/alembic/versions/d6c9452c3940_add_discord_py_2_0_avatar_support.py b/alembic/versions/d6c9452c3940_add_discord_py_2_0_avatar_support.py index 1fcfe9b..751aa65 100644 --- a/alembic/versions/d6c9452c3940_add_discord_py_2_0_avatar_support.py +++ b/alembic/versions/d6c9452c3940_add_discord_py_2_0_avatar_support.py @@ -1,28 +1,31 @@ -"""Add Discord.py 2.0 avatar support +""" +Add Discord.py 2.0 avatar support. Revision ID: d6c9452c3940 Revises: 911049796159 Create Date: 2021-10-31 12:48:03.323113 """ -from alembic import op import sqlalchemy as sa +from alembic import op # revision identifiers, used by Alembic. -revision = 'd6c9452c3940' -down_revision = '911049796159' +revision = "d6c9452c3940" +down_revision = "911049796159" branch_labels = None depends_on = None -def upgrade(): +def upgrade() -> None: + """Apply the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.add_column('users', sa.Column('guild_avatar_hash', sa.String(), nullable=True)) + op.add_column("users", sa.Column("guild_avatar_hash", sa.String(), nullable=True)) # ### end Alembic commands ### -def downgrade(): +def downgrade() -> None: + """Revert the current migration.""" # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('users', 'guild_avatar_hash') + op.drop_column("users", "guild_avatar_hash") # ### end Alembic commands ### |