diff --git a/migrations/versions/cb2ea87be0bd_document_comments.py b/migrations/versions/cb2ea87be0bd_document_comments.py new file mode 100644 index 0000000..61ba5d7 --- /dev/null +++ b/migrations/versions/cb2ea87be0bd_document_comments.py @@ -0,0 +1,45 @@ +"""document comments + +Revision ID: cb2ea87be0bd +Revises: 2a02384ab925 +Create Date: 2024-12-15 01:24:30.954923 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision: str = 'cb2ea87be0bd' +down_revision: Union[str, None] = '2a02384ab925' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('document_comments', + sa.Column('id', sa.UUID(), nullable=False), + sa.Column('doc_id', sa.UUID(), nullable=True), + sa.Column('author_id', sa.String(), nullable=False), + sa.Column('comment', sa.Text(), nullable=False), + sa.Column('created_at', sa.DateTime(timezone=True), server_default=sa.text('NOW()'), nullable=False), + sa.Column('updated_at', sa.DateTime(timezone=True), server_default=sa.text('NOW()'), nullable=False), + sa.ForeignKeyConstraint(['author_id'], ['users.id'], ), + sa.ForeignKeyConstraint(['doc_id'], ['document_metadata.id'], ondelete='CASCADE'), + sa.PrimaryKeyConstraint('id') + ) + op.create_index(op.f('ix_document_comments_id'), 'document_comments', ['id'], unique=False) + op.drop_index('ix_notify_id', table_name='notify') + op.create_unique_constraint(None, 'share_url', ['url_id']) + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint(None, 'share_url', type_='unique') + op.drop_index(op.f('ix_document_comments_id'), table_name='document_comments') + op.drop_table('document_comments') + # ### end Alembic commands ###