Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ cloudflared.deb
.ruff_cache
.gigaide
coverage.xml
.coverage
.coverage
alembic.ini
148 changes: 0 additions & 148 deletions alembic.ini

This file was deleted.

Binary file removed alembic/__pycache__/env.cpython-313.pyc
Binary file not shown.
102 changes: 102 additions & 0 deletions alembic/versions/4972fe91500d_v0_0_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
"""v0.0.1

Revision ID: 4972fe91500d
Revises: 001
Create Date: 2026-05-31 17:00:41.411887

"""
from typing import Sequence, Union

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision: str = '4972fe91500d'
down_revision: Union[str, Sequence[str], None] = '001'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
"""Upgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('bans',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('reason', sa.String(length=150), nullable=False, comment='Причина бана'),
sa.Column('user_id', sa.Integer(), nullable=False, comment='ID пользователя, который получил бан'),
sa.Column('banned_by', sa.Integer(), nullable=False, comment='Тот, кто выдал бан'),
sa.Column('revoked_by', sa.Integer(), nullable=True, comment='Тот, кто снял бан'),
sa.Column('banned_at', sa.DateTime(timezone=True), nullable=False),
sa.Column('expires_at', sa.DateTime(timezone=True), nullable=True, comment='Время окончания бана'),
sa.Column('revoked_at', sa.DateTime(timezone=True), nullable=True, comment='Время отмены бана'),
sa.Column('revoked_reason', sa.String(length=150), nullable=True, comment='Причина отмены бана'),
sa.CheckConstraint('expires_at IS NULL OR expires_at > banned_at', name='ck_ban_expires_after_banned'),
sa.CheckConstraint('revoked_at IS NULL OR (revoked_at >= banned_at AND (expires_at IS NULL OR revoked_at <= expires_at))', name='ck_ban_revoke_logic'),
sa.ForeignKeyConstraint(['banned_by'], ['users.id'], ),
sa.ForeignKeyConstraint(['revoked_by'], ['users.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_bans_banned_by'), 'bans', ['banned_by'], unique=False)
op.create_index(op.f('ix_bans_revoked_by'), 'bans', ['revoked_by'], unique=False)
op.create_index(op.f('ix_bans_user_id'), 'bans', ['user_id'], unique=False)
op.create_index('uq_active_ban', 'bans', ['user_id'], unique=True, postgresql_where=sa.text('revoked_at IS NULL AND (expires_at IS NULL OR expires_at > now())'))
op.alter_column('appointments', 'comment',
existing_type=sa.VARCHAR(length=1200),
nullable=False)
op.add_column('magic_tokens', sa.Column('user_id', sa.Integer(), nullable=True))
op.create_foreign_key(None, 'magic_tokens', 'users', ['user_id'], ['id'])
op.alter_column('services', 'description',
existing_type=sa.VARCHAR(length=2000),
nullable=False)
op.alter_column('services', 'address',
existing_type=sa.VARCHAR(length=100),
nullable=False)
op.add_column('users', sa.Column('user_role', sa.Enum('user', 'admin', 'moderator'), nullable=False))
Comment thread
Fl1riX marked this conversation as resolved.
op.alter_column('users', 'email',
existing_type=sa.VARCHAR(length=50),
nullable=False)
op.drop_constraint(op.f('users_phone_key'), 'users', type_='unique')
op.drop_constraint(op.f('users_telegram_id_key'), 'users', type_='unique')
op.drop_index(op.f('ix_users_email'), table_name='users')
op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True)
op.drop_index(op.f('ix_users_phone'), table_name='users')
op.create_index(op.f('ix_users_phone'), 'users', ['phone'], unique=True)
op.drop_index(op.f('ix_users_telegram_id'), table_name='users')
op.create_index(op.f('ix_users_telegram_id'), 'users', ['telegram_id'], unique=True)
# ### end Alembic commands ###


def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_users_telegram_id'), table_name='users')
op.create_index(op.f('ix_users_telegram_id'), 'users', ['telegram_id'], unique=False)
op.drop_index(op.f('ix_users_phone'), table_name='users')
op.create_index(op.f('ix_users_phone'), 'users', ['phone'], unique=False)
op.drop_index(op.f('ix_users_email'), table_name='users')
op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=False)
op.create_unique_constraint(op.f('users_telegram_id_key'), 'users', ['telegram_id'], postgresql_nulls_not_distinct=False)
op.create_unique_constraint(op.f('users_phone_key'), 'users', ['phone'], postgresql_nulls_not_distinct=False)
op.alter_column('users', 'email',
existing_type=sa.VARCHAR(length=50),
nullable=True)
op.drop_column('users', 'user_role')
op.alter_column('services', 'address',
existing_type=sa.VARCHAR(length=100),
nullable=True)
op.alter_column('services', 'description',
existing_type=sa.VARCHAR(length=2000),
nullable=True)
op.drop_constraint(None, 'magic_tokens', type_='foreignkey')
Comment thread
Fl1riX marked this conversation as resolved.
op.drop_column('magic_tokens', 'user_id')
op.alter_column('appointments', 'comment',
existing_type=sa.VARCHAR(length=1200),
nullable=True)
op.drop_index('uq_active_ban', table_name='bans', postgresql_where=sa.text('revoked_at IS NULL AND (expires_at IS NULL OR expires_at > now())'))
op.drop_index(op.f('ix_bans_user_id'), table_name='bans')
op.drop_index(op.f('ix_bans_revoked_by'), table_name='bans')
op.drop_index(op.f('ix_bans_banned_by'), table_name='bans')
op.drop_table('bans')
# ### end Alembic commands ###
2 changes: 1 addition & 1 deletion src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@

DATABASE_URL = os.getenv("DATABASE_URL")

SECRET_KEY = os.getenv("SECRET_KEY", "development-secret-key-i-love_coding")
SECRET_KEY = os.getenv("SECRET_KEY")
Comment thread
sourcery-ai[bot] marked this conversation as resolved.
Outdated
ALGORITHM = os.getenv("ALGORITHM", "HS256")
ACCESS_TOKEN_EXPIRE_MINUTES = int(os.getenv("ACCESS_TOKEN_EXPIRE_MINUTES", 30))
Loading