From 1209e69765c5ff1286f0966f6f1bba5720763c9e Mon Sep 17 00:00:00 2001 From: ikhit Date: Wed, 16 Oct 2024 11:28:19 +0300 Subject: [PATCH] fix alembic --- app/alembic.ini | 4 +- ...commit.py => 17c3c5e67c14_first_commit.py} | 7 ++-- .../versions/fd795bdbba90_update_feedback.py | 41 ------------------- app/main.py | 2 +- app/models/models.py | 5 +-- 5 files changed, 8 insertions(+), 51 deletions(-) rename app/alembic/versions/{e8b13ba333a5_first_commit.py => 17c3c5e67c14_first_commit.py} (95%) delete mode 100644 app/alembic/versions/fd795bdbba90_update_feedback.py diff --git a/app/alembic.ini b/app/alembic.ini index ada65d0..578c2ae 100644 --- a/app/alembic.ini +++ b/app/alembic.ini @@ -83,7 +83,7 @@ sqlalchemy.url = driver://user:pass@localhost/dbname keys = root,sqlalchemy,alembic [handlers] -keys = generic +keys = console [formatters] keys = generic @@ -111,4 +111,4 @@ formatter = generic [formatter_generic] format = %(levelname)-5.5s [%(name)s] %(message)s -datefmt = %H:%M:%S +datefmt = %H:%M:%S \ No newline at end of file diff --git a/app/alembic/versions/e8b13ba333a5_first_commit.py b/app/alembic/versions/17c3c5e67c14_first_commit.py similarity index 95% rename from app/alembic/versions/e8b13ba333a5_first_commit.py rename to app/alembic/versions/17c3c5e67c14_first_commit.py index b336f4d..671fb60 100644 --- a/app/alembic/versions/e8b13ba333a5_first_commit.py +++ b/app/alembic/versions/17c3c5e67c14_first_commit.py @@ -1,8 +1,8 @@ """first commit -Revision ID: e8b13ba333a5 +Revision ID: 17c3c5e67c14 Revises: -Create Date: 2024-10-15 13:59:59.402203 +Create Date: 2024-10-16 11:27:25.240035 """ from typing import Sequence, Union @@ -12,7 +12,7 @@ from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. -revision: str = 'e8b13ba333a5' +revision: str = '17c3c5e67c14' down_revision: Union[str, None] = None branch_labels: Union[str, Sequence[str], None] = None depends_on: Union[str, Sequence[str], None] = None @@ -63,6 +63,7 @@ def upgrade() -> None: sa.Column('description', sa.TEXT(), nullable=True), sa.Column('id', sa.Integer(), nullable=False), sa.ForeignKeyConstraint(['product_id'], ['productcategory.id'], ondelete='CASCADE'), + sa.ForeignKeyConstraint(['product_id'], ['productcategory.id'], ondelete='CASCADE'), sa.PrimaryKeyConstraint('id') ) op.create_index(op.f('ix_categorytype_product_id'), 'categorytype', ['product_id'], unique=False) diff --git a/app/alembic/versions/fd795bdbba90_update_feedback.py b/app/alembic/versions/fd795bdbba90_update_feedback.py deleted file mode 100644 index c6f71cc..0000000 --- a/app/alembic/versions/fd795bdbba90_update_feedback.py +++ /dev/null @@ -1,41 +0,0 @@ -"""Update Feedback - -Revision ID: fd795bdbba90 -Revises: -Create Date: 2024-10-11 19:56:11.060934 - -""" - -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 = "fd795bdbba90" -down_revision: Union[str, None] = None -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( - "feedback", - sa.Column("user", sa.Integer(), nullable=False), - sa.Column("rating", sa.INTEGER(), nullable=False), - sa.Column("feedback_text", sa.TEXT(), nullable=False), - sa.Column("feedback_date", postgresql.TIMESTAMP(), nullable=False), - sa.Column("unread", sa.BOOLEAN(), nullable=False), - sa.Column("id", sa.Integer(), nullable=False), - sa.ForeignKeyConstraint(["user"], ["user.id"], ondelete="CASCADE"), - sa.PrimaryKeyConstraint("id"), - ) - # ### end Alembic commands ### - - -def downgrade() -> None: - # ### commands auto generated by Alembic - please adjust! ### - op.drop_table("feedback") - # ### end Alembic commands ### diff --git a/app/main.py b/app/main.py index fbae720..e869d9e 100644 --- a/app/main.py +++ b/app/main.py @@ -9,7 +9,7 @@ from bot.callbacks import router as callback_router from bot.fsm_contexts.manager_context import router as fsm_context_router from bot.fsm_contexts.feedback_context import router as feedback_context -from core.init_db import add_portfolio +from core.init_db import add_portfolio, set_admin from admin.handlers.admin_handlers import admin_router from admin.handlers.user import user_router from loggers.log import setup_logging diff --git a/app/models/models.py b/app/models/models.py index fec8d54..83ac44c 100644 --- a/app/models/models.py +++ b/app/models/models.py @@ -18,10 +18,7 @@ class RoleEnum(str, Enum): class QuestionEnum(str, Enum): GENERAL_QUESTIONS = "Общие вопросы" PROBLEMS_WITH_PRODUCTS = "Проблемы с продуктами" - GENERAL_QUESTIONS = "Общие вопросы" - PROBLEMS_WITH_PRODUCTS = "Проблемы с продуктами" - - + class User(Base): """БД модель пользователя."""