From dda4d22880bce3ab22e5df4a44609d5f2fa697f7 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Thu, 28 Jul 2022 19:28:18 +0200 Subject: [PATCH] Reset DB migrations --- alembic.ini | 4 +- .../1647cef23e9b_incoming_activity_model.py | 46 -- ...8bc1e2_add_indieauth_auth_request_model.py | 43 -- ..._28_1725-f5717d82b3ff_initial_migration.py | 393 ++++++++++++++++++ .../21b9e9d71ba3_add_new_is_transient_flag.py | 38 -- .../2b51ae7047cb_webmention_notifications.py | 32 -- ...69edfb_add_indieauth_access_token_model.py | 42 -- .../69ce9fbdc483_add_webmentions_count.py | 28 -- ...b5bcc918ce_tweak_inbox_objects_metadata.py | 34 -- .../8ae9fc9ac88c_webmention_notifications.py | 34 -- .../93e36ff5c691_allow_activity_forwarding.py | 65 --- ...9c4fc0_webmention_support_for_outgoing_.py | 31 -- .../ba131b14c3a1_initial_migration.py | 223 ---------- ...c8cbfccf885d_keep_track_of_poll_answers.py | 32 -- .../c9f204f5611d_alt_text_for_attachments.py | 32 -- .../versions/e58c1ffadf2e_update_support.py | 28 -- ...406b7d0_poll_questions_answers_handling.py | 49 --- .../fd23d95e5c16_improved_webmentions.py | 48 --- 18 files changed, 395 insertions(+), 807 deletions(-) delete mode 100644 alembic/versions/1647cef23e9b_incoming_activity_model.py delete mode 100644 alembic/versions/192aff8bc1e2_add_indieauth_auth_request_model.py create mode 100644 alembic/versions/2022_07_28_1725-f5717d82b3ff_initial_migration.py delete mode 100644 alembic/versions/21b9e9d71ba3_add_new_is_transient_flag.py delete mode 100644 alembic/versions/2b51ae7047cb_webmention_notifications.py delete mode 100644 alembic/versions/65387f69edfb_add_indieauth_access_token_model.py delete mode 100644 alembic/versions/69ce9fbdc483_add_webmentions_count.py delete mode 100644 alembic/versions/79b5bcc918ce_tweak_inbox_objects_metadata.py delete mode 100644 alembic/versions/8ae9fc9ac88c_webmention_notifications.py delete mode 100644 alembic/versions/93e36ff5c691_allow_activity_forwarding.py delete mode 100644 alembic/versions/afc37d9c4fc0_webmention_support_for_outgoing_.py delete mode 100644 alembic/versions/ba131b14c3a1_initial_migration.py delete mode 100644 alembic/versions/c8cbfccf885d_keep_track_of_poll_answers.py delete mode 100644 alembic/versions/c9f204f5611d_alt_text_for_attachments.py delete mode 100644 alembic/versions/e58c1ffadf2e_update_support.py delete mode 100644 alembic/versions/edea0406b7d0_poll_questions_answers_handling.py delete mode 100644 alembic/versions/fd23d95e5c16_improved_webmentions.py diff --git a/alembic.ini b/alembic.ini index 86d1800..9635f78 100644 --- a/alembic.ini +++ b/alembic.ini @@ -8,7 +8,7 @@ script_location = alembic # Uncomment the line below if you want the files to be prepended with date and time # see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file # for all available tokens -# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s +file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s # sys.path path, will be prepended to sys.path if present. # defaults to the current working directory. @@ -20,7 +20,7 @@ prepend_sys_path = . # installed by adding `alembic[tz]` to the pip requirements # string value is passed to dateutil.tz.gettz() # leave blank for localtime -# timezone = +timezone = UTC # max length of characters to apply to the # "slug" field diff --git a/alembic/versions/1647cef23e9b_incoming_activity_model.py b/alembic/versions/1647cef23e9b_incoming_activity_model.py deleted file mode 100644 index 795cc26..0000000 --- a/alembic/versions/1647cef23e9b_incoming_activity_model.py +++ /dev/null @@ -1,46 +0,0 @@ -"""Incoming activity model - -Revision ID: 1647cef23e9b -Revises: afc37d9c4fc0 -Create Date: 2022-07-14 01:20:16.617984 - -""" -import sqlalchemy as sa - -from alembic import op - -# revision identifiers, used by Alembic. -revision = '1647cef23e9b' -down_revision = 'afc37d9c4fc0' -branch_labels = None -depends_on = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('incoming_activity', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('webmention_source', sa.String(), nullable=True), - sa.Column('sent_by_ap_actor_id', sa.String(), nullable=True), - sa.Column('ap_id', sa.String(), nullable=True), - sa.Column('ap_object', sa.JSON(), nullable=True), - sa.Column('tries', sa.Integer(), nullable=False), - sa.Column('next_try', sa.DateTime(timezone=True), nullable=True), - sa.Column('last_try', sa.DateTime(timezone=True), nullable=True), - sa.Column('is_processed', sa.Boolean(), nullable=False), - sa.Column('is_errored', sa.Boolean(), nullable=False), - sa.Column('error', sa.String(), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - op.create_index(op.f('ix_incoming_activity_ap_id'), 'incoming_activity', ['ap_id'], unique=False) - op.create_index(op.f('ix_incoming_activity_id'), 'incoming_activity', ['id'], unique=False) - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index(op.f('ix_incoming_activity_id'), table_name='incoming_activity') - op.drop_index(op.f('ix_incoming_activity_ap_id'), table_name='incoming_activity') - op.drop_table('incoming_activity') - # ### end Alembic commands ### diff --git a/alembic/versions/192aff8bc1e2_add_indieauth_auth_request_model.py b/alembic/versions/192aff8bc1e2_add_indieauth_auth_request_model.py deleted file mode 100644 index f6b3f3d..0000000 --- a/alembic/versions/192aff8bc1e2_add_indieauth_auth_request_model.py +++ /dev/null @@ -1,43 +0,0 @@ -"""Add IndieAuth auth request model - -Revision ID: 192aff8bc1e2 -Revises: 79b5bcc918ce -Create Date: 2022-07-10 09:55:29.768385 - -""" -import sqlalchemy as sa - -from alembic import op - -# revision identifiers, used by Alembic. -revision = '192aff8bc1e2' -down_revision = '79b5bcc918ce' -branch_labels = None -depends_on = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('indieauth_authorization_request', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('code', sa.String(), nullable=False), - sa.Column('scope', sa.String(), nullable=False), - sa.Column('redirect_uri', sa.String(), nullable=False), - sa.Column('client_id', sa.String(), nullable=False), - sa.Column('code_challenge', sa.String(), nullable=True), - sa.Column('code_challenge_method', sa.String(), nullable=True), - sa.Column('is_used', sa.Boolean(), nullable=False), - sa.PrimaryKeyConstraint('id') - ) - op.create_index(op.f('ix_indieauth_authorization_request_code'), 'indieauth_authorization_request', ['code'], unique=True) - op.create_index(op.f('ix_indieauth_authorization_request_id'), 'indieauth_authorization_request', ['id'], unique=False) - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index(op.f('ix_indieauth_authorization_request_id'), table_name='indieauth_authorization_request') - op.drop_index(op.f('ix_indieauth_authorization_request_code'), table_name='indieauth_authorization_request') - op.drop_table('indieauth_authorization_request') - # ### end Alembic commands ### diff --git a/alembic/versions/2022_07_28_1725-f5717d82b3ff_initial_migration.py b/alembic/versions/2022_07_28_1725-f5717d82b3ff_initial_migration.py new file mode 100644 index 0000000..a184ac1 --- /dev/null +++ b/alembic/versions/2022_07_28_1725-f5717d82b3ff_initial_migration.py @@ -0,0 +1,393 @@ +"""Initial migration + +Revision ID: f5717d82b3ff +Revises: +Create Date: 2022-07-28 17:25:31.081326+00:00 + +""" +import sqlalchemy as sa + +from alembic import op + +# revision identifiers, used by Alembic. +revision = 'f5717d82b3ff' +down_revision = None +branch_labels = None +depends_on = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('actor', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('ap_id', sa.String(), nullable=False), + sa.Column('ap_actor', sa.JSON(), nullable=False), + sa.Column('ap_type', sa.String(), nullable=False), + sa.Column('handle', sa.String(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + with op.batch_alter_table('actor', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_actor_ap_id'), ['ap_id'], unique=True) + batch_op.create_index(batch_op.f('ix_actor_handle'), ['handle'], unique=False) + batch_op.create_index(batch_op.f('ix_actor_id'), ['id'], unique=False) + + op.create_table('inbox', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('actor_id', sa.Integer(), nullable=False), + sa.Column('server', sa.String(), nullable=False), + sa.Column('is_hidden_from_stream', sa.Boolean(), nullable=False), + sa.Column('ap_actor_id', sa.String(), nullable=False), + sa.Column('ap_type', sa.String(), nullable=False), + sa.Column('ap_id', sa.String(), nullable=False), + sa.Column('ap_context', sa.String(), nullable=True), + sa.Column('ap_published_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('ap_object', sa.JSON(), nullable=False), + sa.Column('activity_object_ap_id', sa.String(), nullable=True), + sa.Column('visibility', sa.Enum('PUBLIC', 'UNLISTED', 'FOLLOWERS_ONLY', 'DIRECT', name='visibilityenum'), nullable=False), + sa.Column('relates_to_inbox_object_id', sa.Integer(), nullable=True), + sa.Column('relates_to_outbox_object_id', sa.Integer(), nullable=True), + sa.Column('undone_by_inbox_object_id', sa.Integer(), nullable=True), + sa.Column('liked_via_outbox_object_ap_id', sa.String(), nullable=True), + sa.Column('announced_via_outbox_object_ap_id', sa.String(), nullable=True), + sa.Column('voted_for_answers', sa.JSON(), nullable=True), + sa.Column('is_bookmarked', sa.Boolean(), nullable=False), + sa.Column('is_deleted', sa.Boolean(), nullable=False), + sa.Column('is_transient', sa.Boolean(), server_default='0', nullable=False), + sa.Column('replies_count', sa.Integer(), nullable=False), + sa.Column('og_meta', sa.JSON(), nullable=True), + sa.ForeignKeyConstraint(['actor_id'], ['actor.id'], ), + sa.ForeignKeyConstraint(['relates_to_inbox_object_id'], ['inbox.id'], ), + sa.ForeignKeyConstraint(['relates_to_outbox_object_id'], ['outbox.id'], ), + sa.ForeignKeyConstraint(['undone_by_inbox_object_id'], ['inbox.id'], ), + sa.PrimaryKeyConstraint('id') + ) + with op.batch_alter_table('inbox', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_inbox_activity_object_ap_id'), ['activity_object_ap_id'], unique=False) + batch_op.create_index(batch_op.f('ix_inbox_ap_id'), ['ap_id'], unique=True) + batch_op.create_index(batch_op.f('ix_inbox_ap_type'), ['ap_type'], unique=False) + batch_op.create_index(batch_op.f('ix_inbox_id'), ['id'], unique=False) + + op.create_table('incoming_activity', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('webmention_source', sa.String(), nullable=True), + sa.Column('sent_by_ap_actor_id', sa.String(), nullable=True), + sa.Column('ap_id', sa.String(), nullable=True), + sa.Column('ap_object', sa.JSON(), nullable=True), + sa.Column('tries', sa.Integer(), nullable=False), + sa.Column('next_try', sa.DateTime(timezone=True), nullable=True), + sa.Column('last_try', sa.DateTime(timezone=True), nullable=True), + sa.Column('is_processed', sa.Boolean(), nullable=False), + sa.Column('is_errored', sa.Boolean(), nullable=False), + sa.Column('error', sa.String(), nullable=True), + sa.PrimaryKeyConstraint('id') + ) + with op.batch_alter_table('incoming_activity', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_incoming_activity_ap_id'), ['ap_id'], unique=False) + batch_op.create_index(batch_op.f('ix_incoming_activity_id'), ['id'], unique=False) + + op.create_table('indieauth_authorization_request', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('code', sa.String(), nullable=False), + sa.Column('scope', sa.String(), nullable=False), + sa.Column('redirect_uri', sa.String(), nullable=False), + sa.Column('client_id', sa.String(), nullable=False), + sa.Column('code_challenge', sa.String(), nullable=True), + sa.Column('code_challenge_method', sa.String(), nullable=True), + sa.Column('is_used', sa.Boolean(), nullable=False), + sa.PrimaryKeyConstraint('id') + ) + with op.batch_alter_table('indieauth_authorization_request', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_indieauth_authorization_request_code'), ['code'], unique=True) + batch_op.create_index(batch_op.f('ix_indieauth_authorization_request_id'), ['id'], unique=False) + + op.create_table('outbox', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('is_hidden_from_homepage', sa.Boolean(), nullable=False), + sa.Column('public_id', sa.String(), nullable=False), + sa.Column('ap_type', sa.String(), nullable=False), + sa.Column('ap_id', sa.String(), nullable=False), + sa.Column('ap_context', sa.String(), nullable=True), + sa.Column('ap_object', sa.JSON(), nullable=False), + sa.Column('activity_object_ap_id', sa.String(), nullable=True), + sa.Column('source', sa.String(), nullable=True), + sa.Column('revisions', sa.JSON(), nullable=True), + sa.Column('ap_published_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('visibility', sa.Enum('PUBLIC', 'UNLISTED', 'FOLLOWERS_ONLY', 'DIRECT', name='visibilityenum'), nullable=False), + sa.Column('likes_count', sa.Integer(), nullable=False), + sa.Column('announces_count', sa.Integer(), nullable=False), + sa.Column('replies_count', sa.Integer(), nullable=False), + sa.Column('webmentions_count', sa.Integer(), server_default='0', nullable=False), + sa.Column('og_meta', sa.JSON(), nullable=True), + sa.Column('is_pinned', sa.Boolean(), nullable=False), + sa.Column('is_transient', sa.Boolean(), server_default='0', nullable=False), + sa.Column('is_deleted', sa.Boolean(), nullable=False), + sa.Column('relates_to_inbox_object_id', sa.Integer(), nullable=True), + sa.Column('relates_to_outbox_object_id', sa.Integer(), nullable=True), + sa.Column('relates_to_actor_id', sa.Integer(), nullable=True), + sa.Column('undone_by_outbox_object_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['relates_to_actor_id'], ['actor.id'], ), + sa.ForeignKeyConstraint(['relates_to_inbox_object_id'], ['inbox.id'], ), + sa.ForeignKeyConstraint(['relates_to_outbox_object_id'], ['outbox.id'], ), + sa.ForeignKeyConstraint(['undone_by_outbox_object_id'], ['outbox.id'], ), + sa.PrimaryKeyConstraint('id') + ) + with op.batch_alter_table('outbox', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_outbox_activity_object_ap_id'), ['activity_object_ap_id'], unique=False) + batch_op.create_index(batch_op.f('ix_outbox_ap_id'), ['ap_id'], unique=True) + batch_op.create_index(batch_op.f('ix_outbox_ap_type'), ['ap_type'], unique=False) + batch_op.create_index(batch_op.f('ix_outbox_id'), ['id'], unique=False) + batch_op.create_index(batch_op.f('ix_outbox_public_id'), ['public_id'], unique=False) + + op.create_table('upload', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('content_type', sa.String(), nullable=False), + sa.Column('content_hash', sa.String(), nullable=False), + sa.Column('has_thumbnail', sa.Boolean(), nullable=False), + sa.Column('blurhash', sa.String(), nullable=True), + sa.Column('width', sa.Integer(), nullable=True), + sa.Column('height', sa.Integer(), nullable=True), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('content_hash') + ) + with op.batch_alter_table('upload', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_upload_id'), ['id'], unique=False) + + op.create_table('follower', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('actor_id', sa.Integer(), nullable=False), + sa.Column('inbox_object_id', sa.Integer(), nullable=False), + sa.Column('ap_actor_id', sa.String(), nullable=False), + sa.ForeignKeyConstraint(['actor_id'], ['actor.id'], ), + sa.ForeignKeyConstraint(['inbox_object_id'], ['inbox.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('actor_id'), + sa.UniqueConstraint('ap_actor_id') + ) + with op.batch_alter_table('follower', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_follower_id'), ['id'], unique=False) + + op.create_table('following', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('actor_id', sa.Integer(), nullable=False), + sa.Column('outbox_object_id', sa.Integer(), nullable=False), + sa.Column('ap_actor_id', sa.String(), nullable=False), + sa.ForeignKeyConstraint(['actor_id'], ['actor.id'], ), + sa.ForeignKeyConstraint(['outbox_object_id'], ['outbox.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('actor_id'), + sa.UniqueConstraint('ap_actor_id') + ) + with op.batch_alter_table('following', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_following_id'), ['id'], unique=False) + + op.create_table('indieauth_access_token', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('indieauth_authorization_request_id', sa.Integer(), nullable=True), + sa.Column('access_token', sa.String(), nullable=False), + sa.Column('expires_in', sa.Integer(), nullable=False), + sa.Column('scope', sa.String(), nullable=False), + sa.Column('is_revoked', sa.Boolean(), nullable=False), + sa.ForeignKeyConstraint(['indieauth_authorization_request_id'], ['indieauth_authorization_request.id'], ), + sa.PrimaryKeyConstraint('id') + ) + with op.batch_alter_table('indieauth_access_token', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_indieauth_access_token_access_token'), ['access_token'], unique=True) + batch_op.create_index(batch_op.f('ix_indieauth_access_token_id'), ['id'], unique=False) + + op.create_table('outbox_object_attachment', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('filename', sa.String(), nullable=False), + sa.Column('alt', sa.String(), nullable=True), + sa.Column('outbox_object_id', sa.Integer(), nullable=False), + sa.Column('upload_id', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['outbox_object_id'], ['outbox.id'], ), + sa.ForeignKeyConstraint(['upload_id'], ['upload.id'], ), + sa.PrimaryKeyConstraint('id') + ) + with op.batch_alter_table('outbox_object_attachment', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_outbox_object_attachment_id'), ['id'], unique=False) + + op.create_table('outgoing_activity', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('recipient', sa.String(), nullable=False), + sa.Column('outbox_object_id', sa.Integer(), nullable=True), + sa.Column('inbox_object_id', sa.Integer(), nullable=True), + sa.Column('webmention_target', sa.String(), nullable=True), + sa.Column('tries', sa.Integer(), nullable=False), + sa.Column('next_try', sa.DateTime(timezone=True), nullable=True), + sa.Column('last_try', sa.DateTime(timezone=True), nullable=True), + sa.Column('last_status_code', sa.Integer(), nullable=True), + sa.Column('last_response', sa.String(), nullable=True), + sa.Column('is_sent', sa.Boolean(), nullable=False), + sa.Column('is_errored', sa.Boolean(), nullable=False), + sa.Column('error', sa.String(), nullable=True), + sa.ForeignKeyConstraint(['inbox_object_id'], ['inbox.id'], ), + sa.ForeignKeyConstraint(['outbox_object_id'], ['outbox.id'], ), + sa.PrimaryKeyConstraint('id') + ) + with op.batch_alter_table('outgoing_activity', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_outgoing_activity_id'), ['id'], unique=False) + + op.create_table('poll_answer', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('outbox_object_id', sa.Integer(), nullable=False), + sa.Column('poll_type', sa.String(), nullable=False), + sa.Column('inbox_object_id', sa.Integer(), nullable=False), + sa.Column('actor_id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(), nullable=False), + sa.ForeignKeyConstraint(['actor_id'], ['actor.id'], ), + sa.ForeignKeyConstraint(['inbox_object_id'], ['inbox.id'], ), + sa.ForeignKeyConstraint(['outbox_object_id'], ['outbox.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('outbox_object_id', 'name', 'actor_id', name='uix_outbox_object_id_name_actor_id') + ) + with op.batch_alter_table('poll_answer', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_poll_answer_id'), ['id'], unique=False) + batch_op.create_index('uix_one_of_outbox_object_id_actor_id', ['outbox_object_id', 'actor_id'], unique=True, sqlite_where=sa.text('poll_type = "oneOf"')) + + op.create_table('tagged_outbox_object', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('outbox_object_id', sa.Integer(), nullable=False), + sa.Column('tag', sa.String(), nullable=False), + sa.ForeignKeyConstraint(['outbox_object_id'], ['outbox.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('outbox_object_id', 'tag', name='uix_tagged_object') + ) + with op.batch_alter_table('tagged_outbox_object', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_tagged_outbox_object_id'), ['id'], unique=False) + batch_op.create_index(batch_op.f('ix_tagged_outbox_object_tag'), ['tag'], unique=False) + + op.create_table('webmention', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('is_deleted', sa.Boolean(), nullable=False), + sa.Column('source', sa.String(), nullable=False), + sa.Column('source_microformats', sa.JSON(), nullable=True), + sa.Column('target', sa.String(), nullable=False), + sa.Column('outbox_object_id', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['outbox_object_id'], ['outbox.id'], ), + sa.PrimaryKeyConstraint('id'), + sa.UniqueConstraint('source', 'target', name='uix_source_target') + ) + with op.batch_alter_table('webmention', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_webmention_id'), ['id'], unique=False) + batch_op.create_index(batch_op.f('ix_webmention_source'), ['source'], unique=True) + batch_op.create_index(batch_op.f('ix_webmention_target'), ['target'], unique=False) + + op.create_table('notifications', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), + sa.Column('notification_type', sa.Enum('NEW_FOLLOWER', 'UNFOLLOW', 'FOLLOW_REQUEST_ACCEPTED', 'FOLLOW_REQUEST_REJECTED', 'LIKE', 'UNDO_LIKE', 'ANNOUNCE', 'UNDO_ANNOUNCE', 'MENTION', 'NEW_WEBMENTION', 'UPDATED_WEBMENTION', 'DELETED_WEBMENTION', name='notificationtype'), nullable=True), + sa.Column('is_new', sa.Boolean(), nullable=False), + sa.Column('actor_id', sa.Integer(), nullable=True), + sa.Column('outbox_object_id', sa.Integer(), nullable=True), + sa.Column('inbox_object_id', sa.Integer(), nullable=True), + sa.Column('webmention_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['actor_id'], ['actor.id'], ), + sa.ForeignKeyConstraint(['inbox_object_id'], ['inbox.id'], ), + sa.ForeignKeyConstraint(['outbox_object_id'], ['outbox.id'], ), + sa.ForeignKeyConstraint(['webmention_id'], ['webmention.id'], name='fk_webmention_id'), + sa.PrimaryKeyConstraint('id') + ) + with op.batch_alter_table('notifications', schema=None) as batch_op: + batch_op.create_index(batch_op.f('ix_notifications_id'), ['id'], unique=False) + + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('notifications', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_notifications_id')) + + op.drop_table('notifications') + with op.batch_alter_table('webmention', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_webmention_target')) + batch_op.drop_index(batch_op.f('ix_webmention_source')) + batch_op.drop_index(batch_op.f('ix_webmention_id')) + + op.drop_table('webmention') + with op.batch_alter_table('tagged_outbox_object', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_tagged_outbox_object_tag')) + batch_op.drop_index(batch_op.f('ix_tagged_outbox_object_id')) + + op.drop_table('tagged_outbox_object') + with op.batch_alter_table('poll_answer', schema=None) as batch_op: + batch_op.drop_index('uix_one_of_outbox_object_id_actor_id', sqlite_where=sa.text('poll_type = "oneOf"')) + batch_op.drop_index(batch_op.f('ix_poll_answer_id')) + + op.drop_table('poll_answer') + with op.batch_alter_table('outgoing_activity', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_outgoing_activity_id')) + + op.drop_table('outgoing_activity') + with op.batch_alter_table('outbox_object_attachment', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_outbox_object_attachment_id')) + + op.drop_table('outbox_object_attachment') + with op.batch_alter_table('indieauth_access_token', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_indieauth_access_token_id')) + batch_op.drop_index(batch_op.f('ix_indieauth_access_token_access_token')) + + op.drop_table('indieauth_access_token') + with op.batch_alter_table('following', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_following_id')) + + op.drop_table('following') + with op.batch_alter_table('follower', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_follower_id')) + + op.drop_table('follower') + with op.batch_alter_table('upload', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_upload_id')) + + op.drop_table('upload') + with op.batch_alter_table('outbox', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_outbox_public_id')) + batch_op.drop_index(batch_op.f('ix_outbox_id')) + batch_op.drop_index(batch_op.f('ix_outbox_ap_type')) + batch_op.drop_index(batch_op.f('ix_outbox_ap_id')) + batch_op.drop_index(batch_op.f('ix_outbox_activity_object_ap_id')) + + op.drop_table('outbox') + with op.batch_alter_table('indieauth_authorization_request', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_indieauth_authorization_request_id')) + batch_op.drop_index(batch_op.f('ix_indieauth_authorization_request_code')) + + op.drop_table('indieauth_authorization_request') + with op.batch_alter_table('incoming_activity', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_incoming_activity_id')) + batch_op.drop_index(batch_op.f('ix_incoming_activity_ap_id')) + + op.drop_table('incoming_activity') + with op.batch_alter_table('inbox', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_inbox_id')) + batch_op.drop_index(batch_op.f('ix_inbox_ap_type')) + batch_op.drop_index(batch_op.f('ix_inbox_ap_id')) + batch_op.drop_index(batch_op.f('ix_inbox_activity_object_ap_id')) + + op.drop_table('inbox') + with op.batch_alter_table('actor', schema=None) as batch_op: + batch_op.drop_index(batch_op.f('ix_actor_id')) + batch_op.drop_index(batch_op.f('ix_actor_handle')) + batch_op.drop_index(batch_op.f('ix_actor_ap_id')) + + op.drop_table('actor') + # ### end Alembic commands ### diff --git a/alembic/versions/21b9e9d71ba3_add_new_is_transient_flag.py b/alembic/versions/21b9e9d71ba3_add_new_is_transient_flag.py deleted file mode 100644 index c747a12..0000000 --- a/alembic/versions/21b9e9d71ba3_add_new_is_transient_flag.py +++ /dev/null @@ -1,38 +0,0 @@ -"""Add new is_transient flag - -Revision ID: 21b9e9d71ba3 -Revises: edea0406b7d0 -Create Date: 2022-07-24 12:33:15.421906 - -""" -import sqlalchemy as sa - -from alembic import op - -# revision identifiers, used by Alembic. -revision = '21b9e9d71ba3' -down_revision = 'edea0406b7d0' -branch_labels = None -depends_on = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('inbox', schema=None) as batch_op: - batch_op.add_column(sa.Column('is_transient', sa.Boolean(), server_default='0', nullable=False)) - - with op.batch_alter_table('outbox', schema=None) as batch_op: - batch_op.add_column(sa.Column('is_transient', sa.Boolean(), server_default='0', nullable=False)) - - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('outbox', schema=None) as batch_op: - batch_op.drop_column('is_transient') - - with op.batch_alter_table('inbox', schema=None) as batch_op: - batch_op.drop_column('is_transient') - - # ### end Alembic commands ### diff --git a/alembic/versions/2b51ae7047cb_webmention_notifications.py b/alembic/versions/2b51ae7047cb_webmention_notifications.py deleted file mode 100644 index a72eb87..0000000 --- a/alembic/versions/2b51ae7047cb_webmention_notifications.py +++ /dev/null @@ -1,32 +0,0 @@ -"""Webmention notifications - -Revision ID: 2b51ae7047cb -Revises: e58c1ffadf2e -Create Date: 2022-07-19 20:22:06.968951 - -""" -import sqlalchemy as sa - -from alembic import op - -# revision identifiers, used by Alembic. -revision = '2b51ae7047cb' -down_revision = 'e58c1ffadf2e' -branch_labels = None -depends_on = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('notifications', schema=None) as batch_op: - batch_op.create_foreign_key('fk_webmention_id', 'webmention', ['webmention_id'], ['id']) - - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('notifications', schema=None) as batch_op: - batch_op.drop_constraint('fk_webmention_id', type_='foreignkey') - - # ### end Alembic commands ### diff --git a/alembic/versions/65387f69edfb_add_indieauth_access_token_model.py b/alembic/versions/65387f69edfb_add_indieauth_access_token_model.py deleted file mode 100644 index 2ba207d..0000000 --- a/alembic/versions/65387f69edfb_add_indieauth_access_token_model.py +++ /dev/null @@ -1,42 +0,0 @@ -"""Add IndieAuth access token model - -Revision ID: 65387f69edfb -Revises: 192aff8bc1e2 -Create Date: 2022-07-10 10:21:23.652014 - -""" -import sqlalchemy as sa - -from alembic import op - -# revision identifiers, used by Alembic. -revision = '65387f69edfb' -down_revision = '192aff8bc1e2' -branch_labels = None -depends_on = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('indieauth_access_token', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('indieauth_authorization_request_id', sa.Integer(), nullable=True), - sa.Column('access_token', sa.String(), nullable=False), - sa.Column('expires_in', sa.Integer(), nullable=False), - sa.Column('scope', sa.String(), nullable=False), - sa.Column('is_revoked', sa.Boolean(), nullable=False), - sa.ForeignKeyConstraint(['indieauth_authorization_request_id'], ['indieauth_authorization_request.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_index(op.f('ix_indieauth_access_token_access_token'), 'indieauth_access_token', ['access_token'], unique=True) - op.create_index(op.f('ix_indieauth_access_token_id'), 'indieauth_access_token', ['id'], unique=False) - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index(op.f('ix_indieauth_access_token_id'), table_name='indieauth_access_token') - op.drop_index(op.f('ix_indieauth_access_token_access_token'), table_name='indieauth_access_token') - op.drop_table('indieauth_access_token') - # ### end Alembic commands ### diff --git a/alembic/versions/69ce9fbdc483_add_webmentions_count.py b/alembic/versions/69ce9fbdc483_add_webmentions_count.py deleted file mode 100644 index 4a15626..0000000 --- a/alembic/versions/69ce9fbdc483_add_webmentions_count.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Add webmentions count - -Revision ID: 69ce9fbdc483 -Revises: 1647cef23e9b -Create Date: 2022-07-14 15:35:01.716133 - -""" -import sqlalchemy as sa - -from alembic import op - -# revision identifiers, used by Alembic. -revision = '69ce9fbdc483' -down_revision = '1647cef23e9b' -branch_labels = None -depends_on = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('outbox', sa.Column('webmentions_count', sa.Integer(), server_default='0', nullable=False)) - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('outbox', 'webmentions_count') - # ### end Alembic commands ### diff --git a/alembic/versions/79b5bcc918ce_tweak_inbox_objects_metadata.py b/alembic/versions/79b5bcc918ce_tweak_inbox_objects_metadata.py deleted file mode 100644 index 1ea5e22..0000000 --- a/alembic/versions/79b5bcc918ce_tweak_inbox_objects_metadata.py +++ /dev/null @@ -1,34 +0,0 @@ -"""Tweak inbox objects metadata - -Revision ID: 79b5bcc918ce -Revises: 93e36ff5c691 -Create Date: 2022-07-07 18:03:46.945044 - -""" -import sqlalchemy as sa - -from alembic import op - -# revision identifiers, used by Alembic. -revision = '79b5bcc918ce' -down_revision = '93e36ff5c691' -branch_labels = None -depends_on = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('inbox', sa.Column('is_deleted', sa.Boolean(), nullable=False, server_default="0")) - op.add_column('inbox', sa.Column('replies_count', sa.Integer(), nullable=False, server_default="0")) - op.drop_column('inbox', 'has_replies') - op.create_index(op.f('ix_outgoing_activity_id'), 'outgoing_activity', ['id'], unique=False) - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index(op.f('ix_outgoing_activity_id'), table_name='outgoing_activity') - op.add_column('inbox', sa.Column('has_replies', sa.BOOLEAN(), nullable=False)) - op.drop_column('inbox', 'replies_count') - op.drop_column('inbox', 'is_deleted') - # ### end Alembic commands ### diff --git a/alembic/versions/8ae9fc9ac88c_webmention_notifications.py b/alembic/versions/8ae9fc9ac88c_webmention_notifications.py deleted file mode 100644 index 18893a2..0000000 --- a/alembic/versions/8ae9fc9ac88c_webmention_notifications.py +++ /dev/null @@ -1,34 +0,0 @@ -"""Webmention notifications - -Revision ID: 8ae9fc9ac88c -Revises: 2b51ae7047cb -Create Date: 2022-07-19 21:09:04.786032 - -""" -import sqlalchemy as sa - -from alembic import op - -# revision identifiers, used by Alembic. -revision = '8ae9fc9ac88c' -down_revision = '2b51ae7047cb' -branch_labels = None -depends_on = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('notifications', schema=None) as batch_op: - batch_op.add_column(sa.Column('webmention_id', sa.Integer(), nullable=True)) - batch_op.create_foreign_key('fk_webmention_id', 'webmention', ['webmention_id'], ['id']) - - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('notifications', schema=None) as batch_op: - batch_op.drop_constraint('fk_webmention_id', type_='foreignkey') - batch_op.drop_column('webmention_id') - - # ### end Alembic commands ### diff --git a/alembic/versions/93e36ff5c691_allow_activity_forwarding.py b/alembic/versions/93e36ff5c691_allow_activity_forwarding.py deleted file mode 100644 index 46b6b81..0000000 --- a/alembic/versions/93e36ff5c691_allow_activity_forwarding.py +++ /dev/null @@ -1,65 +0,0 @@ -"""Allow activity forwarding - -Revision ID: 93e36ff5c691 -Revises: ba131b14c3a1 -Create Date: 2022-07-06 09:03:57.656539 - -""" -import sqlalchemy as sa -from sqlalchemy.schema import CreateTable - -from alembic import op -from app.database import engine -from app.models import OutgoingActivity - -# revision identifiers, used by Alembic. -revision = '93e36ff5c691' -down_revision = 'ba131b14c3a1' -branch_labels = None -depends_on = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.create_index(op.f('ix_inbox_activity_object_ap_id'), 'inbox', ['activity_object_ap_id'], unique=False) - op.create_index(op.f('ix_inbox_ap_type'), 'inbox', ['ap_type'], unique=False) - op.create_index(op.f('ix_outbox_activity_object_ap_id'), 'outbox', ['activity_object_ap_id'], unique=False) - op.create_index(op.f('ix_outbox_ap_type'), 'outbox', ['ap_type'], unique=False) - # ### end Alembic commands ### - # XXX: cannot remove alter to make a column nullable, we have to drop/recreate it - create_statement = CreateTable(OutgoingActivity.__table__).compile(engine) - op.execute("DROP TABLE IF EXISTS outgoing_activity;") - op.execute(f"{create_statement};") - # Instead of this: - # op.add_column('outgoing_activity', sa.Column('inbox_object_id', sa.Integer(), nullable=True)) - # op.alter_column('outgoing_activity', 'outbox_object_id', - # existing_type=sa.INTEGER(), - # nullable=True) - # op.create_foreign_key(None, 'outgoing_activity', 'inbox', ['inbox_object_id'], ['id']) - # op.create_foreign_key(None, 'outgoing_activity', 'outbox', ['outbox_object_id'], ['id']) - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table("outgoing_activity") - op.create_table('outgoing_activity', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('recipient', sa.String(), nullable=False), - sa.Column('outbox_object_id', sa.Integer(), nullable=False), - sa.Column('tries', sa.Integer(), nullable=False), - sa.Column('next_try', sa.DateTime(timezone=True), nullable=True), - sa.Column('last_try', sa.DateTime(timezone=True), nullable=True), - sa.Column('last_status_code', sa.Integer(), nullable=True), - sa.Column('last_response', sa.String(), nullable=True), - sa.Column('is_sent', sa.Boolean(), nullable=False), - sa.Column('is_errored', sa.Boolean(), nullable=False), - sa.Column('error', sa.String(), nullable=True), - sa.ForeignKeyConstraint(['outbox_object_id'], ['outbox.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.drop_index(op.f('ix_outbox_ap_type'), table_name='outbox') - op.drop_index(op.f('ix_outbox_activity_object_ap_id'), table_name='outbox') - op.drop_index(op.f('ix_inbox_ap_type'), table_name='inbox') - op.drop_index(op.f('ix_inbox_activity_object_ap_id'), table_name='inbox') - # ### end Alembic commands ### diff --git a/alembic/versions/afc37d9c4fc0_webmention_support_for_outgoing_.py b/alembic/versions/afc37d9c4fc0_webmention_support_for_outgoing_.py deleted file mode 100644 index 1476342..0000000 --- a/alembic/versions/afc37d9c4fc0_webmention_support_for_outgoing_.py +++ /dev/null @@ -1,31 +0,0 @@ -"""Webmention support for outgoing activties - -Revision ID: afc37d9c4fc0 -Revises: 65387f69edfb -Create Date: 2022-07-10 14:20:46.311098 - -""" -import sqlalchemy as sa - -from alembic import op - -# revision identifiers, used by Alembic. -revision = 'afc37d9c4fc0' -down_revision = '65387f69edfb' -branch_labels = None -depends_on = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - # op.drop_column('outgoing_activity', 'webmention_target') - # op.add_column('outgoing_activity', sa.Column('webmention_target', sa.String(), nullable=True)) - # ### end Alembic commands ### - pass - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - # op.drop_column('outgoing_activity', 'webmention_target') - # ### end Alembic commands ### - pass diff --git a/alembic/versions/ba131b14c3a1_initial_migration.py b/alembic/versions/ba131b14c3a1_initial_migration.py deleted file mode 100644 index 627a89d..0000000 --- a/alembic/versions/ba131b14c3a1_initial_migration.py +++ /dev/null @@ -1,223 +0,0 @@ -"""Initial migration - -Revision ID: ba131b14c3a1 -Revises: -Create Date: 2022-06-26 14:36:44.107422 - -""" -import sqlalchemy as sa - -from alembic import op - -# revision identifiers, used by Alembic. -revision = 'ba131b14c3a1' -down_revision = None -branch_labels = None -depends_on = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('actor', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('ap_id', sa.String(), nullable=False), - sa.Column('ap_actor', sa.JSON(), nullable=False), - sa.Column('ap_type', sa.String(), nullable=False), - sa.Column('handle', sa.String(), nullable=True), - sa.PrimaryKeyConstraint('id') - ) - op.create_index(op.f('ix_actor_ap_id'), 'actor', ['ap_id'], unique=True) - op.create_index(op.f('ix_actor_handle'), 'actor', ['handle'], unique=False) - op.create_index(op.f('ix_actor_id'), 'actor', ['id'], unique=False) - op.create_table('inbox', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('actor_id', sa.Integer(), nullable=False), - sa.Column('server', sa.String(), nullable=False), - sa.Column('is_hidden_from_stream', sa.Boolean(), nullable=False), - sa.Column('ap_actor_id', sa.String(), nullable=False), - sa.Column('ap_type', sa.String(), nullable=False), - sa.Column('ap_id', sa.String(), nullable=False), - sa.Column('ap_context', sa.String(), nullable=True), - sa.Column('ap_published_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('ap_object', sa.JSON(), nullable=False), - sa.Column('activity_object_ap_id', sa.String(), nullable=True), - sa.Column('visibility', sa.Enum('PUBLIC', 'UNLISTED', 'DIRECT', name='visibilityenum'), nullable=False), - sa.Column('relates_to_inbox_object_id', sa.Integer(), nullable=True), - sa.Column('relates_to_outbox_object_id', sa.Integer(), nullable=True), - sa.Column('undone_by_inbox_object_id', sa.Integer(), nullable=True), - sa.Column('liked_via_outbox_object_ap_id', sa.String(), nullable=True), - sa.Column('announced_via_outbox_object_ap_id', sa.String(), nullable=True), - sa.Column('is_bookmarked', sa.Boolean(), nullable=False), - sa.Column('has_replies', sa.Boolean(), nullable=False), - sa.Column('og_meta', sa.JSON(), nullable=True), - sa.ForeignKeyConstraint(['actor_id'], ['actor.id'], ), - sa.ForeignKeyConstraint(['relates_to_inbox_object_id'], ['inbox.id'], ), - sa.ForeignKeyConstraint(['relates_to_outbox_object_id'], ['outbox.id'], ), - sa.ForeignKeyConstraint(['undone_by_inbox_object_id'], ['inbox.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_index(op.f('ix_inbox_ap_id'), 'inbox', ['ap_id'], unique=True) - op.create_index(op.f('ix_inbox_id'), 'inbox', ['id'], unique=False) - op.create_table('outbox', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('is_hidden_from_homepage', sa.Boolean(), nullable=False), - sa.Column('public_id', sa.String(), nullable=False), - sa.Column('ap_type', sa.String(), nullable=False), - sa.Column('ap_id', sa.String(), nullable=False), - sa.Column('ap_context', sa.String(), nullable=True), - sa.Column('ap_object', sa.JSON(), nullable=False), - sa.Column('activity_object_ap_id', sa.String(), nullable=True), - sa.Column('source', sa.String(), nullable=True), - sa.Column('ap_published_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('visibility', sa.Enum('PUBLIC', 'UNLISTED', 'DIRECT', name='visibilityenum'), nullable=False), - sa.Column('likes_count', sa.Integer(), nullable=False), - sa.Column('announces_count', sa.Integer(), nullable=False), - sa.Column('replies_count', sa.Integer(), nullable=False), - sa.Column('webmentions', sa.JSON(), nullable=True), - sa.Column('og_meta', sa.JSON(), nullable=True), - sa.Column('is_pinned', sa.Boolean(), nullable=False), - sa.Column('is_deleted', sa.Boolean(), nullable=False), - sa.Column('relates_to_inbox_object_id', sa.Integer(), nullable=True), - sa.Column('relates_to_outbox_object_id', sa.Integer(), nullable=True), - sa.Column('relates_to_actor_id', sa.Integer(), nullable=True), - sa.Column('undone_by_outbox_object_id', sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(['relates_to_actor_id'], ['actor.id'], ), - sa.ForeignKeyConstraint(['relates_to_inbox_object_id'], ['inbox.id'], ), - sa.ForeignKeyConstraint(['relates_to_outbox_object_id'], ['outbox.id'], ), - sa.ForeignKeyConstraint(['undone_by_outbox_object_id'], ['outbox.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_index(op.f('ix_outbox_ap_id'), 'outbox', ['ap_id'], unique=True) - op.create_index(op.f('ix_outbox_id'), 'outbox', ['id'], unique=False) - op.create_index(op.f('ix_outbox_public_id'), 'outbox', ['public_id'], unique=False) - op.create_table('upload', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('content_type', sa.String(), nullable=False), - sa.Column('content_hash', sa.String(), nullable=False), - sa.Column('has_thumbnail', sa.Boolean(), nullable=False), - sa.Column('blurhash', sa.String(), nullable=True), - sa.Column('width', sa.Integer(), nullable=True), - sa.Column('height', sa.Integer(), nullable=True), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('content_hash') - ) - op.create_index(op.f('ix_upload_id'), 'upload', ['id'], unique=False) - op.create_table('follower', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('actor_id', sa.Integer(), nullable=False), - sa.Column('inbox_object_id', sa.Integer(), nullable=False), - sa.Column('ap_actor_id', sa.String(), nullable=False), - sa.ForeignKeyConstraint(['actor_id'], ['actor.id'], ), - sa.ForeignKeyConstraint(['inbox_object_id'], ['inbox.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('actor_id'), - sa.UniqueConstraint('ap_actor_id') - ) - op.create_index(op.f('ix_follower_id'), 'follower', ['id'], unique=False) - op.create_table('following', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('updated_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('actor_id', sa.Integer(), nullable=False), - sa.Column('outbox_object_id', sa.Integer(), nullable=False), - sa.Column('ap_actor_id', sa.String(), nullable=False), - sa.ForeignKeyConstraint(['actor_id'], ['actor.id'], ), - sa.ForeignKeyConstraint(['outbox_object_id'], ['outbox.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('actor_id'), - sa.UniqueConstraint('ap_actor_id') - ) - op.create_index(op.f('ix_following_id'), 'following', ['id'], unique=False) - op.create_table('notifications', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('notification_type', sa.Enum('NEW_FOLLOWER', 'UNFOLLOW', 'LIKE', 'UNDO_LIKE', 'ANNOUNCE', 'UNDO_ANNOUNCE', 'MENTION', name='notificationtype'), nullable=True), - sa.Column('is_new', sa.Boolean(), nullable=False), - sa.Column('actor_id', sa.Integer(), nullable=True), - sa.Column('outbox_object_id', sa.Integer(), nullable=True), - sa.Column('inbox_object_id', sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(['actor_id'], ['actor.id'], ), - sa.ForeignKeyConstraint(['inbox_object_id'], ['inbox.id'], ), - sa.ForeignKeyConstraint(['outbox_object_id'], ['outbox.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_index(op.f('ix_notifications_id'), 'notifications', ['id'], unique=False) - op.create_table('outbox_object_attachment', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('filename', sa.String(), nullable=False), - sa.Column('outbox_object_id', sa.Integer(), nullable=False), - sa.Column('upload_id', sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(['outbox_object_id'], ['outbox.id'], ), - sa.ForeignKeyConstraint(['upload_id'], ['upload.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_index(op.f('ix_outbox_object_attachment_id'), 'outbox_object_attachment', ['id'], unique=False) - op.create_table('outgoing_activity', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('recipient', sa.String(), nullable=False), - sa.Column('outbox_object_id', sa.Integer(), nullable=False), - sa.Column('tries', sa.Integer(), nullable=False), - sa.Column('next_try', sa.DateTime(timezone=True), nullable=True), - sa.Column('last_try', sa.DateTime(timezone=True), nullable=True), - sa.Column('last_status_code', sa.Integer(), nullable=True), - sa.Column('last_response', sa.String(), nullable=True), - sa.Column('is_sent', sa.Boolean(), nullable=False), - sa.Column('is_errored', sa.Boolean(), nullable=False), - sa.Column('error', sa.String(), nullable=True), - sa.ForeignKeyConstraint(['outbox_object_id'], ['outbox.id'], ), - sa.PrimaryKeyConstraint('id') - ) - op.create_index(op.f('ix_outgoing_activity_id'), 'outgoing_activity', ['id'], unique=False) - op.create_table('tagged_outbox_object', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('outbox_object_id', sa.Integer(), nullable=False), - sa.Column('tag', sa.String(), nullable=False), - sa.ForeignKeyConstraint(['outbox_object_id'], ['outbox.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('outbox_object_id', 'tag', name='uix_tagged_object') - ) - op.create_index(op.f('ix_tagged_outbox_object_id'), 'tagged_outbox_object', ['id'], unique=False) - op.create_index(op.f('ix_tagged_outbox_object_tag'), 'tagged_outbox_object', ['tag'], unique=False) - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_index(op.f('ix_tagged_outbox_object_tag'), table_name='tagged_outbox_object') - op.drop_index(op.f('ix_tagged_outbox_object_id'), table_name='tagged_outbox_object') - op.drop_table('tagged_outbox_object') - op.drop_index(op.f('ix_outgoing_activity_id'), table_name='outgoing_activity') - op.drop_table('outgoing_activity') - op.drop_index(op.f('ix_outbox_object_attachment_id'), table_name='outbox_object_attachment') - op.drop_table('outbox_object_attachment') - op.drop_index(op.f('ix_notifications_id'), table_name='notifications') - op.drop_table('notifications') - op.drop_index(op.f('ix_following_id'), table_name='following') - op.drop_table('following') - op.drop_index(op.f('ix_follower_id'), table_name='follower') - op.drop_table('follower') - op.drop_index(op.f('ix_upload_id'), table_name='upload') - op.drop_table('upload') - op.drop_index(op.f('ix_outbox_public_id'), table_name='outbox') - op.drop_index(op.f('ix_outbox_id'), table_name='outbox') - op.drop_index(op.f('ix_outbox_ap_id'), table_name='outbox') - op.drop_table('outbox') - op.drop_index(op.f('ix_inbox_id'), table_name='inbox') - op.drop_index(op.f('ix_inbox_ap_id'), table_name='inbox') - op.drop_table('inbox') - op.drop_index(op.f('ix_actor_id'), table_name='actor') - op.drop_index(op.f('ix_actor_handle'), table_name='actor') - op.drop_index(op.f('ix_actor_ap_id'), table_name='actor') - op.drop_table('actor') - # ### end Alembic commands ### diff --git a/alembic/versions/c8cbfccf885d_keep_track_of_poll_answers.py b/alembic/versions/c8cbfccf885d_keep_track_of_poll_answers.py deleted file mode 100644 index 79ec900..0000000 --- a/alembic/versions/c8cbfccf885d_keep_track_of_poll_answers.py +++ /dev/null @@ -1,32 +0,0 @@ -"""Keep track of poll answers - -Revision ID: c8cbfccf885d -Revises: c9f204f5611d -Create Date: 2022-07-23 19:01:16.289953 - -""" -import sqlalchemy as sa - -from alembic import op - -# revision identifiers, used by Alembic. -revision = 'c8cbfccf885d' -down_revision = 'c9f204f5611d' -branch_labels = None -depends_on = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('inbox', schema=None) as batch_op: - batch_op.add_column(sa.Column('voted_for_answers', sa.JSON(), nullable=True)) - - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('inbox', schema=None) as batch_op: - batch_op.drop_column('voted_for_answers') - - # ### end Alembic commands ### diff --git a/alembic/versions/c9f204f5611d_alt_text_for_attachments.py b/alembic/versions/c9f204f5611d_alt_text_for_attachments.py deleted file mode 100644 index 5da9769..0000000 --- a/alembic/versions/c9f204f5611d_alt_text_for_attachments.py +++ /dev/null @@ -1,32 +0,0 @@ -"""Alt text for attachments - -Revision ID: c9f204f5611d -Revises: 8ae9fc9ac88c -Create Date: 2022-07-21 22:33:41.569754 - -""" -import sqlalchemy as sa - -from alembic import op - -# revision identifiers, used by Alembic. -revision = 'c9f204f5611d' -down_revision = '8ae9fc9ac88c' -branch_labels = None -depends_on = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('outbox_object_attachment', schema=None) as batch_op: - batch_op.add_column(sa.Column('alt', sa.String(), nullable=True)) - - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('outbox_object_attachment', schema=None) as batch_op: - batch_op.drop_column('alt') - - # ### end Alembic commands ### diff --git a/alembic/versions/e58c1ffadf2e_update_support.py b/alembic/versions/e58c1ffadf2e_update_support.py deleted file mode 100644 index 4a3fdb2..0000000 --- a/alembic/versions/e58c1ffadf2e_update_support.py +++ /dev/null @@ -1,28 +0,0 @@ -"""Update support - -Revision ID: e58c1ffadf2e -Revises: fd23d95e5c16 -Create Date: 2022-07-17 18:19:42.362542 - -""" -import sqlalchemy as sa - -from alembic import op - -# revision identifiers, used by Alembic. -revision = 'e58c1ffadf2e' -down_revision = 'fd23d95e5c16' -branch_labels = None -depends_on = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('outbox', sa.Column('revisions', sa.JSON(), nullable=True)) - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_column('outbox', 'revisions') - # ### end Alembic commands ### diff --git a/alembic/versions/edea0406b7d0_poll_questions_answers_handling.py b/alembic/versions/edea0406b7d0_poll_questions_answers_handling.py deleted file mode 100644 index 38b7180..0000000 --- a/alembic/versions/edea0406b7d0_poll_questions_answers_handling.py +++ /dev/null @@ -1,49 +0,0 @@ -"""Poll/Questions answers handling - -Revision ID: edea0406b7d0 -Revises: c8cbfccf885d -Create Date: 2022-07-24 09:49:53.669481 - -""" -import sqlalchemy as sa - -from alembic import op - -# revision identifiers, used by Alembic. -revision = 'edea0406b7d0' -down_revision = 'c8cbfccf885d' -branch_labels = None -depends_on = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('poll_answer', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('outbox_object_id', sa.Integer(), nullable=False), - sa.Column('poll_type', sa.String(), nullable=False), - sa.Column('inbox_object_id', sa.Integer(), nullable=False), - sa.Column('actor_id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(), nullable=False), - sa.ForeignKeyConstraint(['actor_id'], ['actor.id'], ), - sa.ForeignKeyConstraint(['inbox_object_id'], ['inbox.id'], ), - sa.ForeignKeyConstraint(['outbox_object_id'], ['outbox.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('outbox_object_id', 'name', 'actor_id', name='uix_outbox_object_id_name_actor_id') - ) - with op.batch_alter_table('poll_answer', schema=None) as batch_op: - batch_op.create_index(batch_op.f('ix_poll_answer_id'), ['id'], unique=False) - batch_op.create_index('uix_one_of_outbox_object_id_actor_id', ['outbox_object_id', 'actor_id'], unique=True, sqlite_where=sa.text('poll_type = "oneOf"')) - - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - with op.batch_alter_table('poll_answer', schema=None) as batch_op: - batch_op.drop_index('uix_one_of_outbox_object_id_actor_id', sqlite_where=sa.text('poll_type = "oneOf"')) - batch_op.drop_index(batch_op.f('ix_poll_answer_id')) - - op.drop_table('poll_answer') - # ### end Alembic commands ### diff --git a/alembic/versions/fd23d95e5c16_improved_webmentions.py b/alembic/versions/fd23d95e5c16_improved_webmentions.py deleted file mode 100644 index b6a6cc4..0000000 --- a/alembic/versions/fd23d95e5c16_improved_webmentions.py +++ /dev/null @@ -1,48 +0,0 @@ -"""Improved Webmentions - -Revision ID: fd23d95e5c16 -Revises: 69ce9fbdc483 -Create Date: 2022-07-14 16:10:54.202455 - -""" -import sqlalchemy as sa -from sqlalchemy.dialects import sqlite - -from alembic import op - -# revision identifiers, used by Alembic. -revision = 'fd23d95e5c16' -down_revision = '69ce9fbdc483' -branch_labels = None -depends_on = None - - -def upgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.create_table('webmention', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('created_at', sa.DateTime(timezone=True), nullable=False), - sa.Column('is_deleted', sa.Boolean(), nullable=False), - sa.Column('source', sa.String(), nullable=False), - sa.Column('source_microformats', sa.JSON(), nullable=True), - sa.Column('target', sa.String(), nullable=False), - sa.Column('outbox_object_id', sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(['outbox_object_id'], ['outbox.id'], ), - sa.PrimaryKeyConstraint('id'), - sa.UniqueConstraint('source', 'target', name='uix_source_target') - ) - op.create_index(op.f('ix_webmention_id'), 'webmention', ['id'], unique=False) - op.create_index(op.f('ix_webmention_source'), 'webmention', ['source'], unique=True) - op.create_index(op.f('ix_webmention_target'), 'webmention', ['target'], unique=False) - op.drop_column('outbox', 'webmentions') - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.add_column('outbox', sa.Column('webmentions', sqlite.JSON(), nullable=True)) - op.drop_index(op.f('ix_webmention_target'), table_name='webmention') - op.drop_index(op.f('ix_webmention_source'), table_name='webmention') - op.drop_index(op.f('ix_webmention_id'), table_name='webmention') - op.drop_table('webmention') - # ### end Alembic commands ###