add user auth boilerplate

This commit is contained in:
Viktor Barzin 2025-06-11 21:08:11 +00:00
parent 4a65664f4a
commit 4ad04775c9
No known key found for this signature in database
GPG key ID: 4056458DBDBF8863
8 changed files with 275 additions and 4 deletions

View file

@ -4,7 +4,7 @@ from sqlalchemy import engine_from_config
from sqlalchemy import pool
from alembic import context
from models import Listing # Import all models here
from models import Listing, User # Import all models here
from database import engine
import sqlmodel
from sqlmodel import SQLModel

View file

@ -0,0 +1,42 @@
"""add more fields to tables
Revision ID: 73f976506aa8
Revises: 042751f52538
Create Date: 2025-06-11 20:54:05.429912
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import sqlmodel
# revision identifiers, used by Alembic.
revision: str = "73f976506aa8"
down_revision: Union[str, None] = "042751f52538"
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(
"user",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("email", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.Column("password", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(op.f("ix_user_email"), "user", ["email"], unique=True)
# ### end Alembic commands ###
def downgrade() -> None:
"""Downgrade schema."""
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f("ix_user_email"), table_name="user")
op.drop_table("user")
# ### end Alembic commands ###