36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
"""login_attempts for SAC UI login rate limiting
|
|
|
|
Revision ID: 011
|
|
Revises: 010
|
|
"""
|
|
|
|
from typing import Sequence, Union
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "011"
|
|
down_revision: Union[str, None] = "010"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
op.create_table(
|
|
"login_attempts",
|
|
sa.Column("id", sa.Integer(), autoincrement=True, nullable=False),
|
|
sa.Column("ip_address", sa.String(length=64), nullable=False),
|
|
sa.Column("username", sa.String(length=64), nullable=True),
|
|
sa.Column("success", sa.Boolean(), nullable=False),
|
|
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False),
|
|
sa.PrimaryKeyConstraint("id"),
|
|
)
|
|
op.create_index("ix_login_attempts_ip_address", "login_attempts", ["ip_address"], unique=False)
|
|
op.create_index("ix_login_attempts_created_at", "login_attempts", ["created_at"], unique=False)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_index("ix_login_attempts_created_at", table_name="login_attempts")
|
|
op.drop_index("ix_login_attempts_ip_address", table_name="login_attempts")
|
|
op.drop_table("login_attempts")
|