Skip to content

Commit 33cf1b5

Browse files
♻️ Squash Alembic migrations
1 parent 366eb58 commit 33cf1b5

5 files changed

+26
-247
lines changed

backend/app/alembic/versions/1a31ce608336_add_cascade_delete_relationships.py

Lines changed: 0 additions & 37 deletions
This file was deleted.

backend/app/alembic/versions/9c0a54914c78_add_max_length_for_string_varchar_.py

Lines changed: 0 additions & 69 deletions
This file was deleted.

backend/app/alembic/versions/d98dd8ec85a3_edit_replace_id_integers_in_all_models_.py

Lines changed: 0 additions & 90 deletions
This file was deleted.

backend/app/alembic/versions/e2412789c190_initialize_models.py

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
33
Revision ID: e2412789c190
44
Revises:
5-
Create Date: 2023-11-24 22:55:43.195942
5+
Create Date: 2026-02-18 15:03:00.000000
66
77
"""
8-
import sqlalchemy as sa
9-
import sqlmodel.sql.sqltypes
108
from alembic import op
9+
from sqlalchemy.dialects import postgresql
10+
import sqlalchemy as sa
11+
1112

1213
# revision identifiers, used by Alembic.
1314
revision = "e2412789c190"
@@ -16,39 +17,44 @@
1617
depends_on = None
1718

1819

19-
def upgrade():
20-
# ### commands auto generated by Alembic - please adjust! ###
20+
def upgrade() -> None:
21+
op.execute('CREATE EXTENSION IF NOT EXISTS "uuid-ossp"')
2122
op.create_table(
2223
"user",
23-
sa.Column("email", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
24+
sa.Column("email", sa.String(length=255), nullable=False),
2425
sa.Column("is_active", sa.Boolean(), nullable=False),
2526
sa.Column("is_superuser", sa.Boolean(), nullable=False),
26-
sa.Column("full_name", sqlmodel.sql.sqltypes.AutoString(), nullable=True),
27-
sa.Column("id", sa.Integer(), nullable=False),
27+
sa.Column("full_name", sa.String(length=255), nullable=True),
2828
sa.Column(
29-
"hashed_password", sqlmodel.sql.sqltypes.AutoString(), nullable=False
29+
"id",
30+
postgresql.UUID(as_uuid=True),
31+
server_default=sa.text("uuid_generate_v4()"),
32+
nullable=False,
3033
),
34+
sa.Column("hashed_password", sa.String(), nullable=False),
35+
sa.Column("created_at", sa.DateTime(timezone=True), nullable=True),
3136
sa.PrimaryKeyConstraint("id"),
3237
)
3338
op.create_index(op.f("ix_user_email"), "user", ["email"], unique=True)
39+
3440
op.create_table(
3541
"item",
36-
sa.Column("description", sqlmodel.sql.sqltypes.AutoString(), nullable=True),
37-
sa.Column("id", sa.Integer(), nullable=False),
38-
sa.Column("title", sqlmodel.sql.sqltypes.AutoString(), nullable=False),
39-
sa.Column("owner_id", sa.Integer(), nullable=False),
40-
sa.ForeignKeyConstraint(
41-
["owner_id"],
42-
["user.id"],
42+
sa.Column("description", sa.String(length=255), nullable=True),
43+
sa.Column(
44+
"id",
45+
postgresql.UUID(as_uuid=True),
46+
server_default=sa.text("uuid_generate_v4()"),
47+
nullable=False,
4348
),
49+
sa.Column("title", sa.String(length=255), nullable=False),
50+
sa.Column("created_at", sa.DateTime(timezone=True), nullable=True),
51+
sa.Column("owner_id", postgresql.UUID(as_uuid=True), nullable=False),
52+
sa.ForeignKeyConstraint(["owner_id"], ["user.id"], ondelete="CASCADE"),
4453
sa.PrimaryKeyConstraint("id"),
4554
)
46-
# ### end Alembic commands ###
4755

4856

49-
def downgrade():
50-
# ### commands auto generated by Alembic - please adjust! ###
57+
def downgrade() -> None:
5158
op.drop_table("item")
5259
op.drop_index(op.f("ix_user_email"), table_name="user")
5360
op.drop_table("user")
54-
# ### end Alembic commands ###

backend/app/alembic/versions/fe56fa70289e_add_created_at_to_user_and_item.py

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)