Spaces:
Sleeping
Sleeping
shri-jai commited on
Commit ·
cc20cd4
1
Parent(s): 1c73b1f
feat: added ios versioning check
Browse files
alembic/versions/142c69b4cf87_added_ios_link_field_app_version.py
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""added: ios_link field app_version
|
| 2 |
+
|
| 3 |
+
Revision ID: 142c69b4cf87
|
| 4 |
+
Revises: 81425575a724
|
| 5 |
+
Create Date: 2025-12-12 15:10:26.470772
|
| 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 |
+
from sqlalchemy.dialects import postgresql
|
| 14 |
+
|
| 15 |
+
# revision identifiers, used by Alembic.
|
| 16 |
+
revision: str = '142c69b4cf87'
|
| 17 |
+
down_revision: Union[str, Sequence[str], None] = '81425575a724'
|
| 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 |
+
# Drop child tables first to satisfy FK dependencies
|
| 24 |
+
op.drop_table('comments')
|
| 25 |
+
op.drop_table('likes')
|
| 26 |
+
op.drop_table('posts')
|
| 27 |
+
|
| 28 |
+
op.add_column(
|
| 29 |
+
'app_version',
|
| 30 |
+
sa.Column('ios_download_link', sqlmodel.sql.sqltypes.AutoString())
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
op.alter_column(
|
| 34 |
+
"assets",
|
| 35 |
+
"id",
|
| 36 |
+
type_=sa.Uuid(),
|
| 37 |
+
existing_type=sa.VARCHAR(),
|
| 38 |
+
postgresql_using="id::uuid"
|
| 39 |
+
)
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def downgrade() -> None:
|
| 45 |
+
"""Downgrade schema."""
|
| 46 |
+
# ### commands auto generated by Alembic - please adjust! ###
|
| 47 |
+
op.alter_column('assets', 'id',
|
| 48 |
+
existing_type=sa.Uuid(),
|
| 49 |
+
type_=sa.VARCHAR(),
|
| 50 |
+
existing_nullable=False)
|
| 51 |
+
op.drop_column('app_version', 'ios_download_link')
|
| 52 |
+
op.create_table('posts',
|
| 53 |
+
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
| 54 |
+
sa.Column('user_id', sa.UUID(), autoincrement=False, nullable=False),
|
| 55 |
+
sa.Column('type', postgresql.ENUM('BIRTHDAY', 'NOTICE', 'BANNER', 'JOB_REQUEST', name='posttype'), autoincrement=False, nullable=False),
|
| 56 |
+
sa.Column('category', postgresql.ENUM('TEAM', 'GLOBAL', name='postcategory'), autoincrement=False, nullable=False),
|
| 57 |
+
sa.Column('caption', sa.VARCHAR(), autoincrement=False, nullable=True),
|
| 58 |
+
sa.Column('image', sa.VARCHAR(), autoincrement=False, nullable=True),
|
| 59 |
+
sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
|
| 60 |
+
sa.Column('edited_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
|
| 61 |
+
sa.ForeignKeyConstraint(['user_id'], ['users.id'], name='posts_user_id_fkey'),
|
| 62 |
+
sa.PrimaryKeyConstraint('id', name='posts_pkey'),
|
| 63 |
+
postgresql_ignore_search_path=False
|
| 64 |
+
)
|
| 65 |
+
op.create_table('likes',
|
| 66 |
+
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
| 67 |
+
sa.Column('post_id', sa.UUID(), autoincrement=False, nullable=False),
|
| 68 |
+
sa.Column('user_id', sa.UUID(), autoincrement=False, nullable=False),
|
| 69 |
+
sa.Column('liked_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
|
| 70 |
+
sa.ForeignKeyConstraint(['post_id'], ['posts.id'], name=op.f('likes_post_id_fkey')),
|
| 71 |
+
sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('likes_user_id_fkey')),
|
| 72 |
+
sa.PrimaryKeyConstraint('id', name=op.f('likes_pkey')),
|
| 73 |
+
sa.UniqueConstraint('user_id', 'post_id', name=op.f('likes_user_id_post_id_key'), postgresql_include=[], postgresql_nulls_not_distinct=False)
|
| 74 |
+
)
|
| 75 |
+
op.create_table('comments',
|
| 76 |
+
sa.Column('id', sa.UUID(), autoincrement=False, nullable=False),
|
| 77 |
+
sa.Column('post_id', sa.UUID(), autoincrement=False, nullable=False),
|
| 78 |
+
sa.Column('user_id', sa.UUID(), autoincrement=False, nullable=False),
|
| 79 |
+
sa.Column('comment', sa.VARCHAR(), autoincrement=False, nullable=False),
|
| 80 |
+
sa.Column('created_at', postgresql.TIMESTAMP(), autoincrement=False, nullable=False),
|
| 81 |
+
sa.ForeignKeyConstraint(['post_id'], ['posts.id'], name=op.f('comments_post_id_fkey')),
|
| 82 |
+
sa.ForeignKeyConstraint(['user_id'], ['users.id'], name=op.f('comments_user_id_fkey')),
|
| 83 |
+
sa.PrimaryKeyConstraint('id', name=op.f('comments_pkey'))
|
| 84 |
+
)
|
| 85 |
+
# ### end Alembic commands ###
|
src/core/models.py
CHANGED
|
@@ -33,7 +33,7 @@ class AppVersion(SQLModel, table=True):
|
|
| 33 |
__tablename__ = "app_version"
|
| 34 |
version: str = Field(primary_key=True)
|
| 35 |
apk_download_link: str
|
| 36 |
-
|
| 37 |
|
| 38 |
class Users(SQLModel, table=True):
|
| 39 |
__tablename__ = "users"
|
|
|
|
| 33 |
__tablename__ = "app_version"
|
| 34 |
version: str = Field(primary_key=True)
|
| 35 |
apk_download_link: str
|
| 36 |
+
ios_download_link: str
|
| 37 |
|
| 38 |
class Users(SQLModel, table=True):
|
| 39 |
__tablename__ = "users"
|
src/core/router.py
CHANGED
|
@@ -19,12 +19,15 @@ async def get_app_config(
|
|
| 19 |
|
| 20 |
min_version = row.version if row else "0.0.0"
|
| 21 |
apk_url = row.apk_download_link if row else ""
|
|
|
|
| 22 |
|
| 23 |
return BaseResponse(
|
| 24 |
status_code=200,
|
| 25 |
data=AppConfigResponse(
|
| 26 |
version=min_version,
|
| 27 |
-
apk_download_link=apk_url
|
|
|
|
| 28 |
)
|
| 29 |
)
|
| 30 |
|
|
|
|
|
|
| 19 |
|
| 20 |
min_version = row.version if row else "0.0.0"
|
| 21 |
apk_url = row.apk_download_link if row else ""
|
| 22 |
+
ios_url = row.ios_download_link if row else ""
|
| 23 |
|
| 24 |
return BaseResponse(
|
| 25 |
status_code=200,
|
| 26 |
data=AppConfigResponse(
|
| 27 |
version=min_version,
|
| 28 |
+
apk_download_link=apk_url,
|
| 29 |
+
ios_download_link=ios_url
|
| 30 |
)
|
| 31 |
)
|
| 32 |
|
| 33 |
+
|
src/core/schemas.py
CHANGED
|
@@ -11,4 +11,5 @@ class BaseResponse(BaseModel, Generic[T]):
|
|
| 11 |
|
| 12 |
class AppConfigResponse(SQLModel):
|
| 13 |
version: str
|
| 14 |
-
apk_download_link: str
|
|
|
|
|
|
| 11 |
|
| 12 |
class AppConfigResponse(SQLModel):
|
| 13 |
version: str
|
| 14 |
+
apk_download_link: str
|
| 15 |
+
ios_download_link: str
|