Skip to content

Commit

Permalink
chore: Update source_id field type to CharField in RawEncounter model
Browse files Browse the repository at this point in the history
  • Loading branch information
TanookiVerde committed Jul 22, 2024
1 parent 3ff4d8b commit 3cc2747
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion api/app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class RawEncounter(Model):
"app.DataSource", related_name="raw_encounter_source", null=False
)
source_updated_at = fields.DatetimeField(null=False)
source_id = fields.DatetimeField(null=False)
source_id = fields.CharField(max_length=100, null=False)
is_valid = fields.BooleanField(null=True)
created_at = fields.DatetimeField(auto_now_add=True, index=True)
updated_at = fields.DatetimeField(auto_now=True, index=True)
Expand Down
14 changes: 14 additions & 0 deletions api/migrations/app/23_20240722102840_update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# -*- coding: utf-8 -*-
from tortoise import BaseDBAsyncClient


async def upgrade(db: BaseDBAsyncClient) -> str:
return """
ALTER TABLE "datasource" ALTER COLUMN "system" TYPE VARCHAR(50) USING "system"::VARCHAR(50);
ALTER TABLE "raw__encounter" ALTER COLUMN "source_id" TYPE VARCHAR(100) USING "source_id"::VARCHAR(100);"""


async def downgrade(db: BaseDBAsyncClient) -> str:
return """
ALTER TABLE "datasource" ALTER COLUMN "system" TYPE VARCHAR(50) USING "system"::VARCHAR(50);
ALTER TABLE "raw__encounter" ALTER COLUMN "source_id" TYPE TIMESTAMPTZ USING "source_id"::TIMESTAMPTZ;"""

0 comments on commit 3cc2747

Please sign in to comment.