feat: add is_active to organizations
Problem
It is not possible to temporarily disable access to an organization. The current workaround is to disable all users in the organization by setting is_active = False for these users.
Changes
- Add
is_activeandis_not_active_reasonto organization model - Add migration for ^
- Add
ActiveOrganizationmiddleware to enforce that users are member of an active organization and the current organization in the session is active - Update organization switcher to disable selecting
is_active = Falseorganizations. - Update some data loaders to only load data when the current session has an organization set (current organization).
How did you test this code?
👉 Stay up-to-date with PostHog coding conventions for a smoother review.
- Manual testing - loom demo
- Unit tests
Changelog: (features only) Is this feature complete?
Docs from this PR will be published at posthog.com
| Project | Deployment | Preview | Updated (UTC) |
|---|---|---|---|
| posthog.com | 🤷 Unknown | Preview | Dec 8, 2025, 11:04 PM |
Preview will be ready in ~10 minutes. Click Preview link above to access docs at /handbook/engineering/
Wiz Scan Summary
| Scanner | Findings |
|---|---|
| - | |
| - | |
| - | |
| - | |
| - | |
| Total | - |
To detect these findings earlier in the dev lifecycle, try using Wiz Code VS Code Extension.
Migration SQL Changes
Hey đź‘‹, we've detected some migrations on this PR. Here's the SQL output for each migration, make sure they make sense:
posthog/migrations/0938_organization_is_active_and_more.py
BEGIN;
--
-- Add field is_active to organization
--
ALTER TABLE "posthog_organization" ADD COLUMN "is_active" boolean DEFAULT true NULL;
ALTER TABLE "posthog_organization" ALTER COLUMN "is_active" DROP DEFAULT;
--
-- Add field is_not_active_reason to organization
--
ALTER TABLE "posthog_organization" ADD COLUMN "is_not_active_reason" text NULL;
COMMIT;
Last updated: 2025-12-10 15:41 UTC (bfffa9c)
Size Change: +533 B (+0.01%)
Total Size: 3.66 MB
ℹ️ View Unchanged
| Filename | Size | Change |
|---|---|---|
frontend/dist/toolbar.js |
3.66 MB | +533 B (+0.01%) |
🔍 Migration Risk Analysis
We've analyzed your migrations for potential risks.
Summary: 1 Safe | 0 Needs Review | 0 Blocked
âś… Safe
Brief or no lock, backwards compatible
posthog.0938_organization_is_active_and_more
└─ #1 ✅ AddField
Adding nullable field requires brief lock
model: organization, field: is_active
└─ #2 ✅ AddField
Adding nullable field requires brief lock
model: organization, field: is_not_active_reason
📚 How to Deploy These Changes Safely
AddField:
This operation acquires a brief lock but doesn't rewrite the table.
Deployment uses lock timeouts with automatic retries, so lock contention will cause retries rather than connection pile-up.
Last updated: 2025-12-10 15:41 UTC (bfffa9c)
Query snapshots: Backend query snapshots updated
Changes: 9 snapshots (9 modified, 0 added, 0 deleted)
What this means:
- Query snapshots have been automatically updated to match current output
- These changes reflect modifications to database queries or schema
Next steps:
- Review the query changes to ensure they're intentional
- If unexpected, investigate what caused the query to change
âŹď¸Ź Skipped snapshot commit because branch advanced to 581dd20 while workflow was testing 97402f7.
The new commit will trigger its own snapshot update workflow.
If you expected this workflow to succeed: This can happen due to concurrent commits. To get a fresh workflow run, either:
- Merge master into your branch, or
- Push an empty commit:
git commit --allow-empty -m 'trigger CI' && git push
Query snapshots: Backend query snapshots updated
Changes: 3 snapshots (3 modified, 0 added, 0 deleted)
What this means:
- Query snapshots have been automatically updated to match current output
- These changes reflect modifications to database queries or schema
Next steps:
- Review the query changes to ensure they're intentional
- If unexpected, investigate what caused the query to change
âŹď¸Ź Skipped snapshot commit because branch advanced to 07d77af while workflow was testing 851aa0b.
The new commit will trigger its own snapshot update workflow.
If you expected this workflow to succeed: This can happen due to concurrent commits. To get a fresh workflow run, either:
- Merge master into your branch, or
- Push an empty commit:
git commit --allow-empty -m 'trigger CI' && git push
Visual regression: Storybook UI snapshots updated
Changes: 20 snapshots (20 modified, 0 added, 0 deleted)
What this means:
- Snapshots have been automatically updated to match current rendering
- Next CI run will switch to CHECK mode to verify stability
- If snapshots change again, CHECK mode will fail (indicates flapping)
Next steps:
- Review the changes to ensure they're intentional
- Approve if changes match your expectations
- If unexpected, investigate component rendering
Visual regression: Storybook UI snapshots updated
Changes: 5 snapshots (5 modified, 0 added, 0 deleted)
What this means:
- Snapshots have been automatically updated to match current rendering
- Next CI run will switch to CHECK mode to verify stability
- If snapshots change again, CHECK mode will fail (indicates flapping)
Next steps:
- Review the changes to ensure they're intentional
- Approve if changes match your expectations
- If unexpected, investigate component rendering
Visual regression: Storybook UI snapshots updated
Changes: 1 snapshots (1 modified, 0 added, 0 deleted)
What this means:
- Snapshots have been automatically updated to match current rendering
- Next CI run will switch to CHECK mode to verify stability
- If snapshots change again, CHECK mode will fail (indicates flapping)
Next steps:
- Review the changes to ensure they're intentional
- Approve if changes match your expectations
- If unexpected, investigate component rendering
Query snapshots: Backend query snapshots updated
Changes: 2 snapshots (2 modified, 0 added, 0 deleted)
What this means:
- Query snapshots have been automatically updated to match current output
- These changes reflect modifications to database queries or schema
Next steps:
- Review the query changes to ensure they're intentional
- If unexpected, investigate what caused the query to change
Query snapshots: Backend query snapshots updated
Changes: 2 snapshots (2 modified, 0 added, 0 deleted)
What this means:
- Query snapshots have been automatically updated to match current output
- These changes reflect modifications to database queries or schema
Next steps:
- Review the query changes to ensure they're intentional
- If unexpected, investigate what caused the query to change