-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix a weird issue with other libraries pulling in secrets.py * Add data migration to fill and fix any null schedule.timezone values.
- Loading branch information
1 parent
f57569d
commit 6369d86
Showing
5 changed files
with
121 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
.../appointment/migrations/versions/2024_11_25_1715-e1519cfdc484_fix_timezone_in_schedule.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
"""fix timezone in schedule | ||
Revision ID: e1519cfdc484 | ||
Revises: 71cf5d3ee14b | ||
Create Date: 2024-11-25 17:15:13.027568 | ||
""" | ||
|
||
from alembic import op | ||
from sqlalchemy.orm import Session | ||
|
||
from appointment.database import models | ||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'e1519cfdc484' | ||
down_revision = '71cf5d3ee14b' | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade() -> None: | ||
session = Session(op.get_bind()) | ||
schedules: list[models.Schedule] = session.query(models.Schedule).where(models.Schedule.timezone.is_(None)).all() | ||
for schedule in schedules: | ||
if schedule.owner.timezone: | ||
schedule.timezone = schedule.owner.timezone | ||
else: | ||
# Handle any cases where user timezone may be null | ||
owner = schedule.owner | ||
owner.timezone = 'UTC' | ||
session.add(owner) | ||
schedule.timezone = owner.timezone | ||
|
||
# Add the schedule to the database session and commit (update) it | ||
session.add(schedule) | ||
session.commit() | ||
|
||
|
||
def downgrade() -> None: | ||
pass |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters