Skip to content

Commit e802a5b

Browse files
updating where
1 parent 4d71b6c commit e802a5b

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

condition-api/migrations/versions/0b5a70026d28_set_is_active_for_existing_records.py

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,26 +16,17 @@
1616

1717

1818
def upgrade():
19-
# Set is_active = true for documents that belong to a project
20-
# which has at least one document in the documents table
19+
# Set is_active = true for all existing records not created by cronjob
2120
op.execute("""
22-
UPDATE condition.documents
21+
UPDATE condition.projects
2322
SET is_active = true
24-
WHERE project_id IN (
25-
SELECT DISTINCT project_id
26-
FROM condition.documents
27-
)
23+
WHERE created_by != 'cronjob'
2824
""")
2925

30-
# Set is_active = true for projects that have at least one
31-
# related document in the documents table
3226
op.execute("""
33-
UPDATE condition.projects
27+
UPDATE condition.documents
3428
SET is_active = true
35-
WHERE project_id IN (
36-
SELECT DISTINCT project_id
37-
FROM condition.documents
38-
)
29+
WHERE created_by != 'cronjob'
3930
""")
4031

4132

0 commit comments

Comments
 (0)