Skip to content

Commit

Permalink
fix: Field types for versions
Browse files Browse the repository at this point in the history
- `downloads` and `uploads` were made as non-nullable in database, but
  they're defined as nullable in model.
- `added_on` had wrong field type - it's the same type in DB, but
  differently handled in code. Adjusted migration to match the model.
  • Loading branch information
gbdlin committed Aug 14, 2024
1 parent 7351f92 commit faa3219
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import sqlalchemy as sa
from alembic import op

from database import utils

# revision identifiers, used by Alembic.
revision = "4fc55239b4d6"
down_revision = None
Expand Down Expand Up @@ -44,7 +46,7 @@ def upgrade() -> None:
sa.Column("artifact_id", sa.Integer(), nullable=True),
sa.Column("name", sa.Text(), nullable=True),
sa.Column("hash", sa.Text(), nullable=True),
sa.Column("added_on", sa.DateTime(), nullable=True),
sa.Column("added_on", utils.TZDateTime(), nullable=True),
sa.ForeignKeyConstraint(("artifact_id",), ["artifacts.id"]),
sa.PrimaryKeyConstraint("id"),
)
Expand Down
4 changes: 2 additions & 2 deletions plugin_store/database/models/Version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class Version(Base):
name = Column(Text)
hash = Column(Text)
file_field = Column("file", Text, nullable=True)
downloads = Column(Integer, default=0)
updates = Column(Integer, default=0)
downloads = Column(Integer, default=0, nullable=False)
updates = Column(Integer, default=0, nullable=False)

created = Column("added_on", TZDateTime)

Expand Down

0 comments on commit faa3219

Please sign in to comment.