Shri Jayaram commited on
Commit
e629355
·
unverified ·
2 Parent(s): 718d74b f4478f7

Merge pull request #32 from yuvabe-ai-labs/feat/chatbot

Browse files
alembic/versions/1cbb7317540a_fix_water_log_id_uuid.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import Sequence, Union
2
+
3
+ from alembic import op
4
+ import sqlalchemy as sa
5
+ import uuid
6
+
7
+ # revision identifiers, used by Alembic.
8
+ revision: str = '1cbb7317540a'
9
+ down_revision: Union[str, Sequence[str], None] = '9176b44b89ba'
10
+ branch_labels: Union[str, Sequence[str], None] = None
11
+ depends_on: Union[str, Sequence[str], None] = None
12
+
13
+
14
+ def upgrade() -> None:
15
+ """Upgrade schema."""
16
+ # Drop the old id column (this will remove the INTEGER id column)
17
+ op.drop_column('water_logs', 'id')
18
+
19
+ # Add the new UUID id column
20
+ op.add_column('water_logs', sa.Column('id', sa.UUID(), nullable=False, primary_key=True, default=uuid.uuid4))
21
+
22
+ # Optional: If you had any foreign key constraints or other indexes on the old id, you might need to add them back.
23
+
24
+ def downgrade() -> None:
25
+ """Downgrade schema."""
26
+ # Drop the UUID id column
27
+ op.drop_column('water_logs', 'id')
28
+
29
+ # Add the original INTEGER id column back
30
+ op.add_column('water_logs', sa.Column('id', sa.Integer(), nullable=False, primary_key=True))
31
+
32
+ # Optional: Restore any other changes you might have made during the downgrade
alembic/versions/9176b44b89ba_added_water_logs_table.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """added: water_logs table
2
+
3
+ Revision ID: 9176b44b89ba
4
+ Revises: e96769f268bc
5
+ Create Date: 2025-11-29 21:28:42.789611
6
+
7
+ """
8
+ from typing import Sequence, Union
9
+
10
+ from alembic import op
11
+ import sqlalchemy as sa
12
+ import sqlmodel.sql.sqltypes
13
+
14
+
15
+ # revision identifiers, used by Alembic.
16
+ revision: str = '9176b44b89ba'
17
+ down_revision: Union[str, Sequence[str], None] = 'e96769f268bc'
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
+ # ### commands auto generated by Alembic - please adjust! ###
25
+ op.create_table('water_logs',
26
+ sa.Column('id', sa.Integer(), nullable=False),
27
+ sa.Column('user_id', sa.UUID(), nullable=False),
28
+ sa.Column('amount_ml', sa.Integer(), nullable=False),
29
+ sa.Column('logged_at', sa.DateTime(), nullable=False),
30
+ sa.Column('goal_ml', sa.Integer(), nullable=True),
31
+ sa.Column('recommended_ml', sa.Integer(), nullable=True),
32
+ sa.ForeignKeyConstraint(['user_id'], ['users.id'], ondelete='CASCADE'),
33
+ sa.PrimaryKeyConstraint('id')
34
+ )
35
+ # ### end Alembic commands ###
36
+
37
+
38
+ def downgrade() -> None:
39
+ """Downgrade schema."""
40
+ # ### commands auto generated by Alembic - please adjust! ###
41
+ op.drop_table('water_logs')
42
+ # ### end Alembic commands ###
src/core/__init__.py CHANGED
@@ -4,3 +4,4 @@ from src.core import models as core_models
4
  from src.feed import models as feed_models
5
  from src.home import models as home_models
6
  from src.profile import models as profile_models
 
 
4
  from src.feed import models as feed_models
5
  from src.home import models as home_models
6
  from src.profile import models as profile_models
7
+ from src.wellbeing import models as wellbeing_models
src/wellbeing/__init__.py ADDED
File without changes
src/wellbeing/config.py ADDED
File without changes
src/wellbeing/constants.py ADDED
File without changes
src/wellbeing/dependencies.py ADDED
File without changes
src/wellbeing/exceptions.py ADDED
File without changes
src/wellbeing/models.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from sqlmodel import Field, SQLModel, Relationship, ForeignKey,Column
2
+ import uuid
3
+ from datetime import datetime
4
+ from typing import Optional
5
+ from sqlalchemy.dialects.postgresql import UUID
6
+
7
+ class WaterLogs(SQLModel, table=True):
8
+ __tablename__ = "water_logs"
9
+ id: uuid.UUID = Field(default_factory=uuid.uuid4, primary_key=True)
10
+ user_id: uuid.UUID = Field(
11
+ sa_column=Column(UUID(as_uuid=True), ForeignKey("users.id", ondelete="CASCADE"), nullable=False)
12
+ )
13
+ amount_ml: int = Field(..., nullable=False)
14
+ logged_at: datetime = Field(default_factory=datetime.now, nullable=False)
15
+ goal_ml: Optional[int] = Field(default=None, nullable=True)
16
+ recommended_ml: Optional[int] = Field(default=None, nullable=True)
17
+
18
+ user: "Users" = Relationship(back_populates="water_logs")
src/wellbeing/router.py ADDED
File without changes
src/wellbeing/schemas.py ADDED
File without changes
src/wellbeing/service.py ADDED
File without changes
src/wellbeing/utils.py ADDED
File without changes