mirror of
https://github.com/MrSedan/neuro-reply-bot-reworked.git
synced 2026-01-14 13:39:42 +03:00
Added image table
This commit is contained in:
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@@ -10,5 +10,6 @@
|
||||
"**/.ruby-lsp": true,
|
||||
"**/venv": true,
|
||||
"**/__pycache__": true
|
||||
}
|
||||
},
|
||||
"editor.glyphMargin": true
|
||||
}
|
||||
38
alembic/versions/ca01506184b5_added_image_table.py
Normal file
38
alembic/versions/ca01506184b5_added_image_table.py
Normal file
@@ -0,0 +1,38 @@
|
||||
"""Added image table
|
||||
|
||||
Revision ID: ca01506184b5
|
||||
Revises: 9de2db27ca6e
|
||||
Create Date: 2023-11-04 02:21:28.077631
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = 'ca01506184b5'
|
||||
down_revision: Union[str, None] = '9de2db27ca6e'
|
||||
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('photo',
|
||||
sa.Column('message_id', sa.Integer(), nullable=False),
|
||||
sa.Column('media_group_id', sa.Integer(), nullable=False),
|
||||
sa.Column('post_id', sa.Uuid(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['post_id'], ['post.uuid'], ),
|
||||
sa.PrimaryKeyConstraint('message_id')
|
||||
)
|
||||
op.drop_column('post', 'images')
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('post', sa.Column('images', sa.VARCHAR(), autoincrement=False, nullable=False))
|
||||
op.drop_table('photo')
|
||||
# ### end Alembic commands ###
|
||||
@@ -47,7 +47,14 @@ class Post(Base):
|
||||
from_user_id: Mapped[int] = mapped_column(ForeignKey('admin.user_id'))
|
||||
user: Mapped['Admin'] = relationship(back_populates='posts')
|
||||
text: Mapped[str]
|
||||
images: Mapped[str]
|
||||
images: Mapped[List['Image']] = relationship(back_populates='post', cascade='all, delete')
|
||||
|
||||
class Image(Base):
|
||||
__tablename__ = 'photo'
|
||||
message_id: Mapped[int] = mapped_column(primary_key=True)
|
||||
media_group_id: Mapped[int]
|
||||
post: Mapped['Post'] = relationship(back_populates='images')
|
||||
post_id: Mapped[int] = mapped_column(ForeignKey('post.uuid'))
|
||||
|
||||
if __name__ == '__main__':
|
||||
Base.metadata.create_all(engine)
|
||||
Reference in New Issue
Block a user