Skip to content

Commit 0391d9d

Browse files
committed
Backfill moderation status based on AnnotationModeration
1 parent 79a36c7 commit 0391d9d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Backfill moderation_status based on AnnotationModeration."""
2+
3+
import sqlalchemy as sa
4+
from alembic import op
5+
6+
revision = "077e087027b1"
7+
down_revision = "2aacaede8542"
8+
9+
10+
def upgrade() -> None:
11+
conn = op.get_bind()
12+
13+
result = conn.execute(
14+
sa.text(
15+
"""
16+
UPDATE annotation
17+
SET moderation_status = 'DENIED'
18+
FROM annotation_moderation
19+
WHERE annotation.id = annotation_moderation.annotation_id
20+
AND annotation.moderation_status is null
21+
"""
22+
)
23+
)
24+
print("\tUpdated annotation rows as DENIED:", result.rowcount) # noqa: T201
25+
26+
27+
def downgrade() -> None:
28+
pass

0 commit comments

Comments
 (0)