Skip to content

Commit 71ab841

Browse files
committed
first migration
1 parent 7a42d12 commit 71ab841

3 files changed

Lines changed: 38 additions & 3 deletions

File tree

app/alembic/env.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77

88
from alembic import context
99

10-
from app.core.models.base import Base
11-
from app.core.config import settings
10+
from core.models.base import Base
11+
from core.config import settings
1212

1313
# this is the Alembic Config object, which provides
1414
# access to the values within the .ini file in use.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
"""create users table
2+
3+
Revision ID: 85cf836b1bce
4+
Revises:
5+
Create Date: 2025-03-16 21:29:34.989701
6+
7+
"""
8+
9+
from typing import Sequence, Union
10+
11+
from alembic import op
12+
import sqlalchemy as sa
13+
14+
15+
# revision identifiers, used by Alembic.
16+
revision: str = "85cf836b1bce"
17+
down_revision: Union[str, None] = None
18+
branch_labels: Union[str, Sequence[str], None] = None
19+
depends_on: Union[str, Sequence[str], None] = None
20+
21+
22+
def upgrade() -> None:
23+
"""Upgrade schema."""
24+
op.create_table(
25+
"user",
26+
sa.Column("id", sa.Integer(), nullable=False),
27+
sa.Column("username", sa.String(), nullable=False),
28+
sa.PrimaryKeyConstraint("id"),
29+
sa.UniqueConstraint("username"),
30+
)
31+
32+
33+
def downgrade() -> None:
34+
"""Downgrade schema."""
35+
op.drop_table("user")

app/core/models/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Base(DeclarativeBase):
66

77
@declared_attr
88
def __tablename__(cls) -> str:
9-
return cls.__name__.lower()
9+
return f"{cls.__name__.lower()}s"
1010

1111
id: Mapped[int] = mapped_column(primary_key=True)
1212

0 commit comments

Comments
 (0)