Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
41 changes: 41 additions & 0 deletions backend/app/alembic/versions/8d7a05fd0ad4_item_table_drop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""item table drop

Revision ID: 8d7a05fd0ad4
Revises: c43313eca57d
Create Date: 2025-04-08 15:26:46.613516

"""
from alembic import op
import sqlalchemy as sa
import sqlmodel.sql.sqltypes


# revision identifiers, used by Alembic.
revision = "8d7a05fd0ad4"
down_revision = "c43313eca57d"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table("item")
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"item",
sa.Column(
"description", sa.VARCHAR(length=255), autoincrement=False, nullable=True
),
sa.Column("title", sa.VARCHAR(length=255), autoincrement=False, nullable=False),
sa.Column("id", sa.UUID(), autoincrement=False, nullable=False),
sa.Column("owner_id", sa.UUID(), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(
["owner_id"], ["user.id"], name="item_owner_id_fkey", ondelete="CASCADE"
),
sa.PrimaryKeyConstraint("id", name="item_pkey"),
)
# ### end Alembic commands ###
2 changes: 0 additions & 2 deletions backend/app/api/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from app.api.routes import (
api_keys,
documents,
items,
login,
organization,
project,
Expand All @@ -19,7 +18,6 @@
api_router.include_router(login.router)
api_router.include_router(users.router)
api_router.include_router(utils.router)
api_router.include_router(items.router)
api_router.include_router(documents.router)
api_router.include_router(threads.router)
api_router.include_router(organization.router)
Expand Down
109 changes: 0 additions & 109 deletions backend/app/api/routes/items.py

This file was deleted.

3 changes: 0 additions & 3 deletions backend/app/api/routes/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from app.core.security import get_password_hash, verify_password
from app.crud import create_user, get_user_by_email, update_user
from app.models import (
Item,
Message,
UpdatePassword,
User,
Expand Down Expand Up @@ -219,8 +218,6 @@ def delete_user(
raise HTTPException(
status_code=403, detail="Super users are not allowed to delete themselves"
)
statement = delete(Item).where(col(Item.owner_id) == user_id)
session.exec(statement) # type: ignore
session.delete(user)
session.commit()
return Message(message="User deleted successfully")
1 change: 0 additions & 1 deletion backend/app/crud/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from .user import (
authenticate,
create_item,
create_user,
get_user_by_email,
update_user,
Expand Down
10 changes: 1 addition & 9 deletions backend/app/crud/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from sqlmodel import Session, select

from app.core.security import get_password_hash, verify_password
from app.models import Item, ItemCreate, User, UserCreate, UserUpdate
from app.models import User, UserCreate, UserUpdate


def create_user(*, session: Session, user_create: UserCreate) -> User:
Expand Down Expand Up @@ -44,11 +44,3 @@ def authenticate(*, session: Session, email: str, password: str) -> User | None:
if not verify_password(password, db_user.hashed_password):
return None
return db_user


def create_item(*, session: Session, item_in: ItemCreate, owner_id: uuid.UUID) -> Item:
db_item = Item.model_validate(item_in, update={"owner_id": owner_id})
session.add(db_item)
session.commit()
session.refresh(db_item)
return db_item
2 changes: 1 addition & 1 deletion backend/app/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from .auth import Token, TokenPayload
from .document import Document
from .item import Item, ItemCreate, ItemPublic, ItemsPublic, ItemUpdate

from .message import Message

from .project_user import (
Expand Down
42 changes: 0 additions & 42 deletions backend/app/models/item.py

This file was deleted.

1 change: 0 additions & 1 deletion backend/app/models/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ class UpdatePassword(SQLModel):
class User(UserBase, table=True):
id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
hashed_password: str
items: list["Item"] = Relationship(back_populates="owner", cascade_delete=True)
documents: list["Document"] = Relationship(
back_populates="owner", cascade_delete=True
)
Expand Down
Loading