ruff formatter

This commit is contained in:
IluaAir
2025-06-22 12:52:52 +03:00
parent 0a5e8a62eb
commit c1fab8feea
9 changed files with 92 additions and 60 deletions

View File

@@ -6,7 +6,7 @@ from sqlalchemy import pool
from alembic import context
from src.db.database import Base
from src.models import * # noqa
from src.models import * # noqa
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
@@ -68,9 +68,7 @@ def run_migrations_online() -> None:
)
with connectable.connect() as connection:
context.configure(
connection=connection, target_metadata=target_metadata
)
context.configure(connection=connection, target_metadata=target_metadata)
with context.begin_transaction():
context.run_migrations()

View File

@@ -1,17 +1,18 @@
"""init
Revision ID: 932121e6b220
Revises:
Revises:
Create Date: 2025-06-22 11:52:49.691545
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
revision: str = '932121e6b220'
revision: str = "932121e6b220"
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
@@ -19,41 +20,68 @@ depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
op.create_table('users',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('username', sa.String(length=30), nullable=False),
sa.Column('telegram_id', sa.BigInteger(), nullable=True),
sa.Column('avatar_path', sa.String(length=255), nullable=True),
sa.Column('email', sa.String(length=320), nullable=False),
sa.Column('hashed_password', sa.String(length=1024), nullable=False),
sa.Column('is_active', sa.Boolean(), nullable=False),
sa.Column('is_superuser', sa.Boolean(), nullable=False),
sa.Column('is_verified', sa.Boolean(), nullable=False),
sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
sa.PrimaryKeyConstraint('id')
op.create_table(
"users",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("username", sa.String(length=30), nullable=False),
sa.Column("telegram_id", sa.BigInteger(), nullable=True),
sa.Column("avatar_path", sa.String(length=255), nullable=True),
sa.Column("email", sa.String(length=320), nullable=False),
sa.Column("hashed_password", sa.String(length=1024), nullable=False),
sa.Column("is_active", sa.Boolean(), nullable=False),
sa.Column("is_superuser", sa.Boolean(), nullable=False),
sa.Column("is_verified", sa.Boolean(), nullable=False),
sa.Column(
"created_at",
sa.TIMESTAMP(timezone=True),
server_default=sa.text("(CURRENT_TIMESTAMP)"),
nullable=False,
),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
op.create_index(op.f('ix_users_username'), 'users', ['username'], unique=True)
op.create_table('tasks',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('title', sa.String(length=100), nullable=False),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('due_date', sa.Date(), nullable=True),
sa.Column('status', sa.Enum('open', 'closed', 'in_progress', 'todo', name='status_enum'), nullable=False),
sa.CheckConstraint("status IN ('open', 'closed', 'in_progress', 'todo')", name="ck_status_enum"),
sa.Column('priority', sa.Enum('low', 'medium', 'high', 'critical', name='priority_enum'), nullable=False),
sa.CheckConstraint("priority in ('low', 'medium', 'high', 'critical')", name='ck_priority_enum'),
sa.Column('time_spent', sa.Integer(), nullable=False),
sa.Column('created_at', sa.TIMESTAMP(timezone=True), server_default=sa.text('(CURRENT_TIMESTAMP)'), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
op.create_index(op.f("ix_users_email"), "users", ["email"], unique=True)
op.create_index(op.f("ix_users_username"), "users", ["username"], unique=True)
op.create_table(
"tasks",
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
sa.Column("user_id", sa.Integer(), nullable=False),
sa.Column("title", sa.String(length=100), nullable=False),
sa.Column("description", sa.Text(), nullable=True),
sa.Column("due_date", sa.Date(), nullable=True),
sa.Column(
"status",
sa.Enum("open", "closed", "in_progress", "todo", name="status_enum"),
nullable=False,
),
sa.CheckConstraint(
"status IN ('open', 'closed', 'in_progress', 'todo')", name="ck_status_enum"
),
sa.Column(
"priority",
sa.Enum("low", "medium", "high", "critical", name="priority_enum"),
nullable=False,
),
sa.CheckConstraint(
"priority in ('low', 'medium', 'high', 'critical')", name="ck_priority_enum"
),
sa.Column("time_spent", sa.Integer(), nullable=False),
sa.Column(
"created_at",
sa.TIMESTAMP(timezone=True),
server_default=sa.text("(CURRENT_TIMESTAMP)"),
nullable=False,
),
sa.ForeignKeyConstraint(
["user_id"],
["users.id"],
),
sa.PrimaryKeyConstraint("id"),
)
def downgrade() -> None:
"""Downgrade schema."""
op.drop_table('tasks')
op.drop_index(op.f('ix_users_username'), table_name='users')
op.drop_index(op.f('ix_users_email'), table_name='users')
op.drop_table('users')
op.drop_table("tasks")
op.drop_index(op.f("ix_users_username"), table_name="users")
op.drop_index(op.f("ix_users_email"), table_name="users")
op.drop_table("users")

View File

@@ -5,6 +5,7 @@ Revises: 932121e6b220
Create Date: 2025-06-22 12:11:19.223212
"""
from typing import Sequence, Union
import fastapi_users_db_sqlalchemy
@@ -12,25 +13,32 @@ from alembic import op
import sqlalchemy as sa
revision: str = 'bc0bdd74718c'
down_revision: Union[str, None] = '932121e6b220'
revision: str = "bc0bdd74718c"
down_revision: Union[str, None] = "932121e6b220"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
"""Upgrade schema."""
op.create_table('accesstoken',
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('token', sa.String(length=43), nullable=False),
sa.Column('created_at', fastapi_users_db_sqlalchemy.generics.TIMESTAMPAware(timezone=True), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('token')
op.create_table(
"accesstoken",
sa.Column("user_id", sa.Integer(), nullable=False),
sa.Column("token", sa.String(length=43), nullable=False),
sa.Column(
"created_at",
fastapi_users_db_sqlalchemy.generics.TIMESTAMPAware(timezone=True),
nullable=False,
),
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="cascade"),
sa.PrimaryKeyConstraint("token"),
)
op.create_index(
op.f("ix_accesstoken_created_at"), "accesstoken", ["created_at"], unique=False
)
op.create_index(op.f('ix_accesstoken_created_at'), 'accesstoken', ['created_at'], unique=False)
def downgrade() -> None:
"""Downgrade schema."""
op.drop_index(op.f('ix_accesstoken_created_at'), table_name='accesstoken')
op.drop_table('accesstoken')
op.drop_index(op.f("ix_accesstoken_created_at"), table_name="accesstoken")
op.drop_table("accesstoken")