Skip to content

Commit

Permalink
Merge pull request #141 from prefeitura-rio/development
Browse files Browse the repository at this point in the history
Remove field "data_referencia" from professionals pydantic model and Adding a "created_at" field in Patient CNS, Telecom and Address
  • Loading branch information
TanookiVerde committed Jul 8, 2024
2 parents 5867f11 + e5b6252 commit f99f67d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
6 changes: 3 additions & 3 deletions api/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class MergedPatientAddress(Model):
postal_code = fields.CharField(max_length=8, null=True)
period_start = fields.DateField(null=True)
period_end = fields.DateField(null=True)
fingerprint = fields.CharField(max_length=32, null=True)
created_at = fields.DatetimeField(auto_now_add=True)

class Meta:
table = "mrg__patientaddress"
Expand All @@ -220,7 +220,7 @@ class MergedPatientTelecom(Model):
rank = fields.IntField(null=True)
period_start = fields.DateField(null=True)
period_end = fields.DateField(null=True)
fingerprint = fields.CharField(max_length=32, null=True)
created_at = fields.DatetimeField(auto_now_add=True)

class Meta:
table = "mrg__patienttelecom"
Expand All @@ -231,7 +231,7 @@ class MergedPatientCns(Model):
patient = fields.ForeignKeyField("app.MergedPatient", related_name="patient_cns")
value = fields.CharField(max_length=16, unique=True)
is_main = fields.BooleanField(default=False)
fingerprint = fields.CharField(max_length=32, null=True)
created_at = fields.DatetimeField(auto_now_add=True)

class Meta:
table = "mrg__patientcns"
Expand Down
1 change: 0 additions & 1 deletion api/app/pydantic_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,4 +281,3 @@ class ProfessionalModel(BaseModel):
nome: str
cbo: List[OccupationModel]
conselho: List[RegistryModel]
data_referencia: date
16 changes: 16 additions & 0 deletions api/migrations/app/19_20240708142702_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
from tortoise import BaseDBAsyncClient


async def upgrade(db: BaseDBAsyncClient) -> str:
return """
ALTER TABLE "mrg__patientaddress" ADD "created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE "mrg__patientcns" ADD "created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE "mrg__patienttelecom" ADD "created_at" TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP;"""


async def downgrade(db: BaseDBAsyncClient) -> str:
return """
ALTER TABLE "mrg__patientcns" DROP COLUMN "created_at";
ALTER TABLE "mrg__patientaddress" DROP COLUMN "created_at";
ALTER TABLE "mrg__patienttelecom" DROP COLUMN "created_at";"""

0 comments on commit f99f67d

Please sign in to comment.