Add backfill for topic_schedule.latest_topic_id

I doubt the absence of this would have ever been noticed or that adding
this will ever matter for anyone, but I might as well do it properly!
This commit is contained in:
Deimos
2020-07-06 15:51:29 -06:00
parent c4af5c7d57
commit 080aadb131

View File

@@ -28,6 +28,16 @@ def upgrade():
["topic_id"],
)
op.execute(
"""
update topic_schedule set latest_topic_id = (
select topic_id from topics
where schedule_id = topic_schedule.schedule_id
order by created_time desc limit 1
)
"""
)
op.execute(
"""
create or replace function update_topic_schedule_latest_topic_id() returns trigger as $$