221 lines
12 KiB
Python
221 lines
12 KiB
Python
"""Initial migration
|
|
|
|
Revision ID: 714b4a5307c7
|
|
Revises:
|
|
Create Date: 2022-06-23 18:42:56.009810
|
|
|
|
"""
|
|
import sqlalchemy as sa
|
|
|
|
from alembic import op
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision = '714b4a5307c7'
|
|
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_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('undone_by_outbox_object_id', sa.Integer(), nullable=True),
|
|
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 ###
|