kemono2/db/migrations/20230507_00_d10V9-add-service-to-post-incomplete-rewards.py

29 lines
629 B
Python
Raw Normal View History

2024-07-04 21:57:05 +02:00
"""
Add service in table for incomplete posts
"""
from yoyo import step
__depends__ = {"20230408_00_FLSD-add-post-incomplete-rewards"}
steps = [
step(
"""
ALTER TABLE posts_incomplete_rewards ADD COLUMN "user" varchar(255) NULL;
"""
),
step(
"""
UPDATE posts_incomplete_rewards pir
SET "user" = p."user"
FROM posts p
WHERE pir.id = p.id AND pir.service = p.service;
"""
),
step(
"""
CREATE INDEX posts_incomplete_rewards_service_user_idx ON posts_incomplete_rewards USING btree (service, "user");
"""
),
]