Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(feature-flags): apply scheduled flag changes through the facade (#102759)

Yasenc0f3ac6a26bd
diff --git a/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr b/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr
index d360708058ad..59110f8ee9f3 100644
--- a/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr
+++ b/posthog/tasks/test/__snapshots__/test_process_scheduled_changes.ambr
@@ -44,6 +44,36 @@
'''
# ---
# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.10
+ '''
+ SELECT "posthog_featureflag"."id",
+ "posthog_featureflag"."key",
+ "posthog_featureflag"."name",
+ "posthog_featureflag"."filters",
+ "posthog_featureflag"."team_id",
+ "posthog_featureflag"."created_by_id",
+ "posthog_featureflag"."created_at",
+ "posthog_featureflag"."updated_at",
+ "posthog_featureflag"."deleted",
+ "posthog_featureflag"."active",
+ "posthog_featureflag"."archived",
+ "posthog_featureflag"."version",
+ "posthog_featureflag"."last_modified_by_id",
+ "posthog_featureflag"."ensure_experience_continuity",
+ "posthog_featureflag"."usage_dashboard_id",
+ "posthog_featureflag"."has_enriched_analytics",
+ "posthog_featureflag"."is_remote_configuration",
+ "posthog_featureflag"."has_encrypted_payloads",
+ "posthog_featureflag"."evaluation_runtime",
+ "posthog_featureflag"."bucketing_identifier",
+ "posthog_featureflag"."last_called_at"
+ FROM "posthog_featureflag"
+ WHERE (NOT ("posthog_featureflag"."deleted")
+ AND "posthog_featureflag"."id" = 99999)
+ ORDER BY "posthog_featureflag"."id" ASC
+ LIMIT 1
+ '''
+# ---
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.11
'''
SELECT "posthog_featureflag"."active" AS "active",
"posthog_featureflag"."deleted" AS "deleted",
@@ -55,7 +85,7 @@
LIMIT 1
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.11
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.12
'''
SELECT "posthog_featureflag"."key" AS "key"
FROM "posthog_featureflag"
@@ -64,7 +94,7 @@
LIMIT 1
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.12
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.13
'''
SELECT "posthog_filesystem"."team_id",
"posthog_filesystem"."id",
@@ -89,7 +119,7 @@
AND "posthog_filesystem"."shortcut" IS NOT NULL))
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.13
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.14
'''
SELECT "posthog_filesystemshortcut"."id",
"posthog_filesystemshortcut"."team_id",
@@ -112,7 +142,7 @@
AND "posthog_filesystemshortcut"."href" IS NOT NULL))
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.14
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.15
'''
SELECT "posthog_featureflag"."id",
"posthog_featureflag"."key",
@@ -250,7 +280,7 @@
AND (jsonb_path_exists(filters, '$.** ? (@.type == "flag")')))
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.15
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.16
'''
SELECT "posthog_integration"."id",
"posthog_integration"."team_id",
@@ -269,7 +299,7 @@
LIMIT 21
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.16
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.17
'''
SELECT "posthog_organizationintegration"."id",
"posthog_organizationintegration"."organization_id",
@@ -286,7 +316,7 @@
LIMIT 21
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.17
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.18
'''
SELECT "posthog_taggeditem"."id",
"posthog_taggeditem"."tag_id",
@@ -311,7 +341,7 @@
WHERE "posthog_taggeditem"."feature_flag_id" = 99999
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.18
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.19
'''
SELECT "posthog_taggeditem"."id",
"posthog_taggeditem"."tag_id",
@@ -336,7 +366,24 @@
WHERE "posthog_taggeditem"."feature_flag_id" = 99999
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.19
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.2
+ '''
+ SELECT "posthog_organizationintegration"."id",
+ "posthog_organizationintegration"."organization_id",
+ "posthog_organizationintegration"."kind",
+ "posthog_organizationintegration"."integration_id",
+ "posthog_organizationintegration"."config",
+ "posthog_organizationintegration"."sensitive_config",
+ "posthog_organizationintegration"."created_by_id",
+ "posthog_organizationintegration"."created_at",
+ "posthog_organizationintegration"."updated_at"
+ FROM "posthog_organizationintegration"
+ WHERE ("posthog_organizationintegration"."kind" = 'vercel'
+ AND "posthog_organizationintegration"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid)
+ LIMIT 21
+ '''
+# ---
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.20
'''
SELECT "posthog_survey"."id",
"posthog_survey"."team_id",
@@ -381,24 +428,7 @@
WHERE "posthog_survey"."internal_response_sampling_flag_id" = 99999
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.2
- '''
- SELECT "posthog_organizationintegration"."id",
- "posthog_organizationintegration"."organization_id",
- "posthog_organizationintegration"."kind",
- "posthog_organizationintegration"."integration_id",
- "posthog_organizationintegration"."config",
- "posthog_organizationintegration"."sensitive_config",
- "posthog_organizationintegration"."created_by_id",
- "posthog_organizationintegration"."created_at",
- "posthog_organizationintegration"."updated_at"
- FROM "posthog_organizationintegration"
- WHERE ("posthog_organizationintegration"."kind" = 'vercel'
- AND "posthog_organizationintegration"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid)
- LIMIT 21
- '''
-# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.20
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.21
'''
SELECT "posthog_survey"."id",
"posthog_survey"."team_id",
@@ -443,7 +473,7 @@
WHERE "posthog_survey"."internal_response_sampling_flag_id" = 99999
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.21
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.22
'''
SELECT "ee_featureflagroleaccess"."id",
"ee_featureflagroleaccess"."feature_flag_id",
@@ -454,7 +484,7 @@
WHERE "ee_featureflagroleaccess"."feature_flag_id" = 99999
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.22
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.23
'''
SELECT "ee_featureflagroleaccess"."id",
"ee_featureflagroleaccess"."feature_flag_id",
@@ -465,7 +495,7 @@
WHERE "ee_featureflagroleaccess"."feature_flag_id" = 99999
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.23
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.24
'''
SELECT "posthog_organization"."id",
"posthog_organization"."name",
@@ -511,7 +541,7 @@
LIMIT 21
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.24
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.25
'''
SELECT "posthog_team"."id",
"posthog_team"."uuid",
@@ -613,7 +643,7 @@
LIMIT 21
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.25
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.26
'''
SELECT "posthog_featureflag"."id",
"posthog_featureflag"."key",
@@ -650,7 +680,7 @@
LIMIT 21
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.26
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.27
'''
SELECT "posthog_team"."id",
"posthog_team"."uuid",
@@ -752,7 +782,7 @@
LIMIT 21
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.27
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.28
'''
SELECT "posthog_organization"."id",
"posthog_organization"."name",
@@ -798,7 +828,7 @@
LIMIT 21
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.28
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.29
'''
SELECT "posthog_user"."id",
"posthog_user"."password",
@@ -845,36 +875,6 @@
LIMIT 21
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.29
- '''
- SELECT "posthog_featureflag"."id",
- "posthog_featureflag"."key",
- "posthog_featureflag"."name",
- "posthog_featureflag"."filters",
- "posthog_featureflag"."team_id",
- "posthog_featureflag"."created_by_id",
- "posthog_featureflag"."created_at",
- "posthog_featureflag"."updated_at",
- "posthog_featureflag"."deleted",
- "posthog_featureflag"."active",
- "posthog_featureflag"."archived",
- "posthog_featureflag"."version",
- "posthog_featureflag"."last_modified_by_id",
- "posthog_featureflag"."ensure_experience_continuity",
- "posthog_featureflag"."usage_dashboard_id",
- "posthog_featureflag"."has_enriched_analytics",
- "posthog_featureflag"."is_remote_configuration",
- "posthog_featureflag"."has_encrypted_payloads",
- "posthog_featureflag"."evaluation_runtime",
- "posthog_featureflag"."bucketing_identifier",
- "posthog_featureflag"."last_called_at"
- FROM "posthog_featureflag"
- WHERE "posthog_featureflag"."id" = 99999
- LIMIT 21
- FOR
- UPDATE
- '''
-# ---
# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.3
'''
SELECT "posthog_scheduledchange"."id",
@@ -947,6 +947,45 @@
'''
# ---
# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.30
+ '''
+ SELECT "feature_flags_teamfeatureflagpolicyconfig"."require_tags" AS "require_tags"
+ FROM "feature_flags_teamfeatureflagpolicyconfig"
+ WHERE "feature_flags_teamfeatureflagpolicyconfig"."team_id" = 99999
+ ORDER BY "feature_flags_teamfeatureflagpolicyconfig"."team_id" ASC
+ LIMIT 1
+ '''
+# ---
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.31
+ '''
+ SELECT "posthog_featureflag"."id",
+ "posthog_featureflag"."key",
+ "posthog_featureflag"."name",
+ "posthog_featureflag"."filters",
+ "posthog_featureflag"."team_id",
+ "posthog_featureflag"."created_by_id",
+ "posthog_featureflag"."created_at",
+ "posthog_featureflag"."updated_at",
+ "posthog_featureflag"."deleted",
+ "posthog_featureflag"."active",
+ "posthog_featureflag"."archived",
+ "posthog_featureflag"."version",
+ "posthog_featureflag"."last_modified_by_id",
+ "posthog_featureflag"."ensure_experience_continuity",
+ "posthog_featureflag"."usage_dashboard_id",
+ "posthog_featureflag"."has_enriched_analytics",
+ "posthog_featureflag"."is_remote_configuration",
+ "posthog_featureflag"."has_encrypted_payloads",
+ "posthog_featureflag"."evaluation_runtime",
+ "posthog_featureflag"."bucketing_identifier",
+ "posthog_featureflag"."last_called_at"
+ FROM "posthog_featureflag"
+ WHERE "posthog_featureflag"."id" = 99999
+ LIMIT 21
+ FOR
+ UPDATE
+ '''
+# ---
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.32
'''
SELECT "posthog_featureflag"."id",
"posthog_featureflag"."key",
@@ -976,7 +1015,7 @@
LIMIT 1
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.31
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.33
'''
SELECT "posthog_featureflag"."active" AS "active",
"posthog_featureflag"."deleted" AS "deleted",
@@ -988,7 +1027,7 @@
LIMIT 1
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.32
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.34
'''
SELECT "posthog_featureflag"."key" AS "key"
FROM "posthog_featureflag"
@@ -997,7 +1036,7 @@
LIMIT 1
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.33
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.35
'''
SELECT "posthog_filesystem"."team_id",
"posthog_filesystem"."id",
@@ -1022,7 +1061,7 @@
AND "posthog_filesystem"."shortcut" IS NOT NULL))
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.34
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.36
'''
SELECT "posthog_filesystemshortcut"."id",
"posthog_filesystemshortcut"."team_id",
@@ -1045,7 +1084,7 @@
AND "posthog_filesystemshortcut"."href" IS NOT NULL))
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.35
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.37
'''
SELECT "posthog_featureflag"."id",
"posthog_featureflag"."key",
@@ -1183,7 +1222,7 @@
AND (jsonb_path_exists(filters, '$.** ? (@.type == "flag")')))
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.36
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.38
'''
SELECT "posthog_integration"."id",
"posthog_integration"."team_id",
@@ -1202,7 +1241,7 @@
LIMIT 21
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.37
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.39
'''
SELECT "posthog_organizationintegration"."id",
"posthog_organizationintegration"."organization_id",
@@ -1219,7 +1258,44 @@
LIMIT 21
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.38
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.4
+ '''
+ SELECT "posthog_featureflag"."id",
+ "posthog_featureflag"."key",
+ "posthog_featureflag"."name",
+ "posthog_featureflag"."filters",
+ "posthog_featureflag"."team_id",
+ "posthog_featureflag"."created_by_id",
+ "posthog_featureflag"."created_at",
+ "posthog_featureflag"."updated_at",
+ "posthog_featureflag"."deleted",
+ "posthog_featureflag"."active",
+ "posthog_featureflag"."archived",
+ "posthog_featureflag"."version",
+ "posthog_featureflag"."last_modified_by_id",
+ "posthog_featureflag"."ensure_experience_continuity",
+ "posthog_featureflag"."usage_dashboard_id",
+ "posthog_featureflag"."has_enriched_analytics",
+ "posthog_featureflag"."is_remote_configuration",
+ "posthog_featureflag"."has_encrypted_payloads",
+ "posthog_featureflag"."evaluation_runtime",
+ "posthog_featureflag"."bucketing_identifier",
+ "posthog_featureflag"."last_called_at"
+ FROM "posthog_featureflag"
+ INNER JOIN "posthog_team" ON ("posthog_featureflag"."team_id" = "posthog_team"."id")
+ WHERE (NOT ("posthog_featureflag"."deleted")
+ AND ("posthog_featureflag"."team_id" =
+ (SELECT U0."parent_team_id" AS "parent_team_id"
+ FROM "posthog_team" U0
+ WHERE U0."id" = 99999
+ LIMIT 1)
+ OR ("posthog_team"."parent_team_id" IS NULL
+ AND "posthog_featureflag"."team_id" = 99999))
+ AND "posthog_featureflag"."id" = 99999)
+ LIMIT 21
+ '''
+# ---
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.40
'''
SELECT "posthog_taggeditem"."id",
"posthog_taggeditem"."tag_id",
@@ -1244,7 +1320,7 @@
WHERE "posthog_taggeditem"."feature_flag_id" = 99999
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.39
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.41
'''
SELECT "posthog_taggeditem"."id",
"posthog_taggeditem"."tag_id",
@@ -1269,44 +1345,7 @@
WHERE "posthog_taggeditem"."feature_flag_id" = 99999
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.4
- '''
- SELECT "posthog_featureflag"."id",
- "posthog_featureflag"."key",
- "posthog_featureflag"."name",
- "posthog_featureflag"."filters",
- "posthog_featureflag"."team_id",
- "posthog_featureflag"."created_by_id",
- "posthog_featureflag"."created_at",
- "posthog_featureflag"."updated_at",
- "posthog_featureflag"."deleted",
- "posthog_featureflag"."active",
- "posthog_featureflag"."archived",
- "posthog_featureflag"."version",
- "posthog_featureflag"."last_modified_by_id",
- "posthog_featureflag"."ensure_experience_continuity",
- "posthog_featureflag"."usage_dashboard_id",
- "posthog_featureflag"."has_enriched_analytics",
- "posthog_featureflag"."is_remote_configuration",
- "posthog_featureflag"."has_encrypted_payloads",
- "posthog_featureflag"."evaluation_runtime",
- "posthog_featureflag"."bucketing_identifier",
- "posthog_featureflag"."last_called_at"
- FROM "posthog_featureflag"
- INNER JOIN "posthog_team" ON ("posthog_featureflag"."team_id" = "posthog_team"."id")
- WHERE (NOT ("posthog_featureflag"."deleted")
- AND ("posthog_featureflag"."team_id" =
- (SELECT U0."parent_team_id" AS "parent_team_id"
- FROM "posthog_team" U0
- WHERE U0."id" = 99999
- LIMIT 1)
- OR ("posthog_team"."parent_team_id" IS NULL
- AND "posthog_featureflag"."team_id" = 99999))
- AND "posthog_featureflag"."id" = 99999)
- LIMIT 21
- '''
-# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.40
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.42
'''
SELECT "posthog_survey"."id",
"posthog_survey"."team_id",
@@ -1351,7 +1390,7 @@
WHERE "posthog_survey"."internal_response_sampling_flag_id" = 99999
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.41
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.43
'''
SELECT "posthog_survey"."id",
"posthog_survey"."team_id",
@@ -1396,7 +1435,7 @@
WHERE "posthog_survey"."internal_response_sampling_flag_id" = 99999
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.42
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.44
'''
SELECT "ee_featureflagroleaccess"."id",
"ee_featureflagroleaccess"."feature_flag_id",
@@ -1407,7 +1446,7 @@
WHERE "ee_featureflagroleaccess"."feature_flag_id" = 99999
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.43
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.45
'''
SELECT "ee_featureflagroleaccess"."id",
"ee_featureflagroleaccess"."feature_flag_id",
@@ -1418,7 +1457,7 @@
WHERE "ee_featureflagroleaccess"."feature_flag_id" = 99999
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.44
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.46
'''
SELECT "posthog_organization"."id",
"posthog_organization"."name",
@@ -1464,7 +1503,7 @@
LIMIT 21
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.45
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.47
'''
SELECT "posthog_team"."id",
"posthog_team"."uuid",
@@ -1566,58 +1605,6 @@
LIMIT 21
'''
# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.46
- '''
- SELECT "posthog_scheduledchange"."id",
- "posthog_scheduledchange"."record_id",
- "posthog_scheduledchange"."model_name",
- "posthog_scheduledchange"."payload",
- "posthog_scheduledchange"."scheduled_at",
- "posthog_scheduledchange"."executed_at",
- "posthog_scheduledchange"."failure_reason",
- "posthog_scheduledchange"."failure_count",
- "posthog_scheduledchange"."is_recurring",
- "posthog_scheduledchange"."recurrence_interval",
- "posthog_scheduledchange"."last_executed_at",
- "posthog_scheduledchange"."cron_expression",
- "posthog_scheduledchange"."end_date",
- "posthog_scheduledchange"."timezone",
- "posthog_scheduledchange"."team_id",
- "posthog_scheduledchange"."change_request_id",
- "posthog_scheduledchange"."created_at",
- "posthog_scheduledchange"."created_by_id",
- "posthog_scheduledchange"."updated_at"
- FROM "posthog_scheduledchange"
- WHERE "posthog_scheduledchange"."id" = 99999
- LIMIT 21
- '''
-# ---
-# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.47
- '''
- SELECT "posthog_scheduledchange"."id",
- "posthog_scheduledchange"."record_id",
- "posthog_scheduledchange"."model_name",
- "posthog_scheduledchange"."payload",
- "posthog_scheduledchange"."scheduled_at",
- "posthog_scheduledchange"."executed_at",
- "posthog_scheduledchange"."failure_reason",
- "posthog_scheduledchange"."failure_count",
- "posthog_scheduledchange"."is_recurring",
- "posthog_scheduledchange"."recurrence_interval",
- "posthog_scheduledchange"."last_executed_at",
- "posthog_scheduledchange"."cron_expression",
- "posthog_scheduledchange"."end_date",
- "posthog_scheduledchange"."timezone",
- "posthog_scheduledchange"."team_id",
- "posthog_scheduledchange"."change_request_id",
- "posthog_scheduledchange"."created_at",
- "posthog_scheduledchange"."created_by_id",
- "posthog_scheduledchange"."updated_at"
- FROM "posthog_scheduledchange"
- WHERE "posthog_scheduledchange"."id" = 99999
- LIMIT 21
- '''
-# ---
# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.48
'''
SELECT "posthog_scheduledchange"."id",
@@ -1773,6 +1760,58 @@
'''
# ---
# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.50
+ '''
+ SELECT "posthog_scheduledchange"."id",
+ "posthog_scheduledchange"."record_id",
+ "posthog_scheduledchange"."model_name",
+ "posthog_scheduledchange"."payload",
+ "posthog_scheduledchange"."scheduled_at",
+ "posthog_scheduledchange"."executed_at",
+ "posthog_scheduledchange"."failure_reason",
+ "posthog_scheduledchange"."failure_count",
+ "posthog_scheduledchange"."is_recurring",
+ "posthog_scheduledchange"."recurrence_interval",
+ "posthog_scheduledchange"."last_executed_at",
+ "posthog_scheduledchange"."cron_expression",
+ "posthog_scheduledchange"."end_date",
+ "posthog_scheduledchange"."timezone",
+ "posthog_scheduledchange"."team_id",
+ "posthog_scheduledchange"."change_request_id",
+ "posthog_scheduledchange"."created_at",
+ "posthog_scheduledchange"."created_by_id",
+ "posthog_scheduledchange"."updated_at"
+ FROM "posthog_scheduledchange"
+ WHERE "posthog_scheduledchange"."id" = 99999
+ LIMIT 21
+ '''
+# ---
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.51
+ '''
+ SELECT "posthog_scheduledchange"."id",
+ "posthog_scheduledchange"."record_id",
+ "posthog_scheduledchange"."model_name",
+ "posthog_scheduledchange"."payload",
+ "posthog_scheduledchange"."scheduled_at",
+ "posthog_scheduledchange"."executed_at",
+ "posthog_scheduledchange"."failure_reason",
+ "posthog_scheduledchange"."failure_count",
+ "posthog_scheduledchange"."is_recurring",
+ "posthog_scheduledchange"."recurrence_interval",
+ "posthog_scheduledchange"."last_executed_at",
+ "posthog_scheduledchange"."cron_expression",
+ "posthog_scheduledchange"."end_date",
+ "posthog_scheduledchange"."timezone",
+ "posthog_scheduledchange"."team_id",
+ "posthog_scheduledchange"."change_request_id",
+ "posthog_scheduledchange"."created_at",
+ "posthog_scheduledchange"."created_by_id",
+ "posthog_scheduledchange"."updated_at"
+ FROM "posthog_scheduledchange"
+ WHERE "posthog_scheduledchange"."id" = 99999
+ LIMIT 21
+ '''
+# ---
+# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.52
'''
SELECT "posthog_featureflag"."id",
"posthog_featureflag"."key",
@@ -1896,32 +1935,11 @@
# ---
# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.8
'''
- SELECT "posthog_featureflag"."id",
- "posthog_featureflag"."key",
- "posthog_featureflag"."name",
- "posthog_featureflag"."filters",
- "posthog_featureflag"."team_id",
- "posthog_featureflag"."created_by_id",
- "posthog_featureflag"."created_at",
- "posthog_featureflag"."updated_at",
- "posthog_featureflag"."deleted",
- "posthog_featureflag"."active",
- "posthog_featureflag"."archived",
- "posthog_featureflag"."version",
- "posthog_featureflag"."last_modified_by_id",
- "posthog_featureflag"."ensure_experience_continuity",
- "posthog_featureflag"."usage_dashboard_id",
- "posthog_featureflag"."has_enriched_analytics",
- "posthog_featureflag"."is_remote_configuration",
- "posthog_featureflag"."has_encrypted_payloads",
- "posthog_featureflag"."evaluation_runtime",
- "posthog_featureflag"."bucketing_identifier",
- "posthog_featureflag"."last_called_at"
- FROM "posthog_featureflag"
- WHERE "posthog_featureflag"."id" = 99999
- LIMIT 21
- FOR
- UPDATE
+ SELECT "feature_flags_teamfeatureflagpolicyconfig"."require_tags" AS "require_tags"
+ FROM "feature_flags_teamfeatureflagpolicyconfig"
+ WHERE "feature_flags_teamfeatureflagpolicyconfig"."team_id" = 99999
+ ORDER BY "feature_flags_teamfeatureflagpolicyconfig"."team_id" ASC
+ LIMIT 1
'''
# ---
# name: TestProcessScheduledChanges.test_schedule_feature_flag_multiple_changes.9
@@ -1948,9 +1966,9 @@
"posthog_featureflag"."bucketing_identifier",
"posthog_featureflag"."last_called_at"
FROM "posthog_featureflag"
- WHERE (NOT ("posthog_featureflag"."deleted")
- AND "posthog_featureflag"."id" = 99999)
- ORDER BY "posthog_featureflag"."id" ASC
- LIMIT 1
+ WHERE "posthog_featureflag"."id" = 99999
+ LIMIT 21
+ FOR
+ UPDATE
'''
# ---
diff --git a/posthog/test/repo_invariants/feature_flag_gated_writes_baseline.txt b/posthog/test/repo_invariants/feature_flag_gated_writes_baseline.txt
index 4874eae440ab..fce958a4cfb0 100644
--- a/posthog/test/repo_invariants/feature_flag_gated_writes_baseline.txt
+++ b/posthog/test/repo_invariants/feature_flag_gated_writes_baseline.txt
@@ -18,7 +18,6 @@ products/demo/backend/logic/products/hedgebox/matrix.py::HedgeboxMatrix.set_proj
products/early_access_features/backend/api.py::clear_feature_enrollment::feature_flag.filters =
products/feature_flags/backend/api/organization_feature_flag.py::OrganizationFeatureFlagView._copy_feature_flag_to_target::FeatureFlagSerializer()
products/feature_flags/backend/api/organization_feature_flag.py::OrganizationFeatureFlagView._copy_feature_flag_to_target::FeatureFlagSerializer(existing_flag)
-products/feature_flags/backend/models/feature_flag.py::FeatureFlag.scheduled_changes_dispatcher::FeatureFlagSerializer(self)
products/feature_flags/evals/seeders.py::_create_flag::FeatureFlag.objects.create()
products/feature_flags/evals/seeders.py::seed_stale_full_rollout_flag::FeatureFlag.objects.create()
products/feature_flags/evals/seeders.py::seed_stale_partial_rollout_flag::FeatureFlag.objects.create()
diff --git a/posthog/test/repo_invariants/test_feature_flag_gated_writes.py b/posthog/test/repo_invariants/test_feature_flag_gated_writes.py
index e917def0bb3c..84e1325980d1 100644
--- a/posthog/test/repo_invariants/test_feature_flag_gated_writes.py
+++ b/posthog/test/repo_invariants/test_feature_flag_gated_writes.py
@@ -25,7 +25,6 @@ GATED_PATH = {
ALLOWED_REASONS: dict[str, str] = {
"ee/clickhouse/views/experiment_holdouts.py": "holdout edit and delete",
"products/feature_flags/backend/api/organization_feature_flag.py": "copy a flag to other projects",
- "products/feature_flags/backend/models/feature_flag.py": "scheduled change execution",
"products/surveys/backend/api/survey.py": "targeting flag writes and the start/stop mirror of active",
"posthog/api/file_system/registrations.py": "file-system trash and restore flip active",
"products/early_access_features/backend/api.py": "never-fail cleanup when stored filters fail validation",
diff --git a/products/feature_flags/backend/models/feature_flag.py b/products/feature_flags/backend/models/feature_flag.py
index 871d6dc3d174..c3799294c550 100644
--- a/products/feature_flags/backend/models/feature_flag.py
+++ b/products/feature_flags/backend/models/feature_flag.py
@@ -450,7 +450,7 @@ class FeatureFlag(Taggable, FileSystemSyncMixin, ModelActivityMixin, RootTeamMix
user: Optional[AbstractBaseUser] = None,
scheduled_change_id: Optional[int] = None,
):
- from products.feature_flags.backend.api.feature_flag import FeatureFlagSerializer
+ from products.feature_flags.backend.facade.api import update_flag
if "operation" not in payload or "value" not in payload:
raise Exception("Invalid payload")
@@ -464,11 +464,6 @@ class FeatureFlag(Taggable, FileSystemSyncMixin, ModelActivityMixin, RootTeamMix
# It's not the correct type, but it matches enough to get the job done
http_request.user = user or self.created_by # type: ignore
http_request.method = "PATCH" # This is a partial update, not a new creation
- context = {
- "request": http_request,
- "team_id": self.team_id,
- "project_id": self.team.project_id,
- }
# Apply-time-only validation for variant changes, before shaping the payload. The gate skips
# these because an invalid change can't be approved into applying anyway; here they surface
@@ -501,9 +496,7 @@ class FeatureFlag(Taggable, FileSystemSyncMixin, ModelActivityMixin, RootTeamMix
if serializer_data is None:
raise Exception(f"Unrecognized operation: {payload['operation']}")
- serializer = FeatureFlagSerializer(self, data=serializer_data, context=context, partial=True)
- if serializer.is_valid(raise_exception=True):
- serializer.save()
+ update_flag(self, serializer_data, team=self.team, user=http_request.user, request=http_request)
@property
def uses_cohorts(self) -> bool: