feat: Added travel models, travel creation command, travels list command with pagination, set help message, improvements and fixes

This commit is contained in:
ITQ
2024-03-23 02:47:05 +03:00
parent 675e5ab891
commit 1802ce81b0
15 changed files with 623 additions and 15 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ from dotenv import load_dotenv
from sqlalchemy import engine_from_config
from sqlalchemy import pool
from app.models.user import Base
from app.models import Base
load_dotenv()
@@ -0,0 +1,97 @@
"""Added travel models
Revision ID: fe4ace4196fb
Revises: 4914f00ae14a
Create Date: 2024-03-22 19:19:36.662090
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'fe4ace4196fb'
down_revision: Union[str, None] = '4914f00ae14a'
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(
'travels',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('title', sa.String(length=50), nullable=False),
sa.Column('description', sa.String(length=100), nullable=True),
sa.Column('author_id', sa.BigInteger(), nullable=False),
sa.ForeignKeyConstraint(
['author_id'],
['users.telegram_id'],
),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('title'),
)
op.create_index(op.f('ix_travels_id'), 'travels', ['id'], unique=True)
op.create_table(
'locations',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('name', sa.Text(), nullable=False),
sa.Column('date_start', sa.Date(), nullable=False),
sa.Column('date_end', sa.Date(), nullable=False),
sa.Column('travel_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(
['travel_id'],
['travels.id'],
),
sa.PrimaryKeyConstraint('id'),
)
op.create_index(op.f('ix_locations_id'), 'locations', ['id'], unique=True)
op.create_table(
'notes',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('file_id', sa.Text(), nullable=False),
sa.Column('file_name', sa.Text(), nullable=False),
sa.Column('file_type', sa.Text(), nullable=False),
sa.Column('public', sa.Boolean(), nullable=False),
sa.Column('author_id', sa.BigInteger(), nullable=False),
sa.Column('travel_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(
['author_id'],
['users.telegram_id'],
),
sa.ForeignKeyConstraint(
['travel_id'],
['travels.id'],
),
sa.PrimaryKeyConstraint('id'),
)
op.create_index(op.f('ix_notes_id'), 'notes', ['id'], unique=True)
op.create_table(
'user_travel_association',
sa.Column('user_id', sa.BigInteger(), nullable=True),
sa.Column('travel_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(
['travel_id'],
['travels.id'],
),
sa.ForeignKeyConstraint(
['user_id'],
['users.telegram_id'],
),
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('user_travel_association')
op.drop_index(op.f('ix_notes_id'), table_name='notes')
op.drop_table('notes')
op.drop_index(op.f('ix_locations_id'), table_name='locations')
op.drop_table('locations')
op.drop_index(op.f('ix_travels_id'), table_name='travels')
op.drop_table('travels')
# ### end Alembic commands ###