Skip to content

fix(db): restore is_demo_org dropped in #1500 - #1628

Merged
reitblatt merged 2 commits into
mainfrom
reitblatt/restore-is-demo-org
Nov 20, 2026
Merged

reitblatt merged 2 commits into
mainfrom
reitblatt/restore-is-demo-org

Conversation

@reitblatt

@reitblatt reitblatt commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Context & Requests for Reviewers

#1500 dropped org_settings.is_demo_org. Current code doesn't use it (#1448 removed it), but released versions up to 1.2.3 still read it (myOrg.isDemoOrg) and write it (ensureOrgSettingsRow). So if you migrate the DB before upgrading the app, or roll the app back, those versions break. #1500 hasn't shipped in a release yet. See RFC #1627 for more context.

This adds a new migration that brings the column back as it was before #1500 (boolean NOT NULL DEFAULT false, no index). It uses ADD COLUMN IF NOT EXISTS with lock_timeout = 5s. With a constant default, Postgres 11+ makes this a metadata-only change. The #1500 migration is unchanged. Current code still doesn't use the column, and a column comment marks it as kept only for compatibility.

Tests (executed by Claude Code)

  • Replayed api-server-pg migrations on a fresh DB, on a DB at the pre-chore(db): remove is_demo_org column from org_settings #1500 state, and on a DB at the post-chore(db): remove is_demo_org column from org_settings #1500 state. All three end up with identical pg_dump -s schemas.
  • Re-ran the migration on an already-migrated DB: it's a no-op.
  • New integration test org-settings-legacy-compat.integ.test.ts runs 1.2.3's org_settings insert and is_demo_org read. It fails without the column and passes with it.
  • pnpm --filter server run typecheck, lint, prettier, and the org GraphQL module and ncmec-org-settings integration tests pass.

(Optional) Rollout Plan

#1500 hasn't shipped, so deployments <= 1.2.3 that upgrade run #1500's drop and then this migration back to back. While the two run, a live 1.2.3 app can briefly fail org-settings queries. If the 5s lock timeout is hit, rerun the migration (it is idempotent).

Release notes

Checklist

Only check items that apply to this PR; leave the rest unchecked.

  • If you changed anything user-facing (i.e. user interface or APIs):
    Did you update related docs?

  • If the change is notable (refer to Keep a Changelog conventions):
    Did you fill in the Release notes section above?

  • If this PR fixes a security vulnerability:
    Did you apply the security-update label, or ask a maintainer to? Don't describe the vulnerability here before its advisory is published.

  • If you changed db/src/scripts/** and used CREATE TABLE, ADD COLUMN, or ALTER COLUMN:
    Are as many columns marked NOT NULL as possible? If some columns can sometimes be null depending on other columns, are there CHECK constraints capturing those relationships, and are these also reflected using unions in the associated Kysely types?

  • If you added a new signal in server/services/signalsService/signals/**:
    Did you classify every error case as a permanent error (SignalPermanentError, no retry) or a normal error (retryable)? Any case where the signal can't determine a score should be a SignalPermanentError.

Released app versions (1.2.3 and earlier) still read and write
org_settings.is_demo_org, so dropping it breaks migrating the database
before upgrading the app, and rolling the app back. Re-add it with its
original definition (boolean NOT NULL DEFAULT false). Current app code
keeps not using it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Add an integration test running 1.2.3's org_settings insert and
is_demo_org read, and note in the migration when the column can be
dropped and that a lock timeout can be retried.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

@reitblatt
reitblatt marked this pull request as ready for review November 19, 2026 21:21
@reitblatt
reitblatt requested a review from a team as a code owner November 19, 2026 21:21

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

View guided diff | Turn on auto-fix | Re-trigger cubic

@juanmrad

Copy link
Copy Markdown
Member

I don't think we need integration tests, but fine to keep.

@reitblatt
reitblatt merged commit a9c5c15 into main Nov 20, 2026
34 checks passed
@reitblatt
reitblatt deleted the reitblatt/restore-is-demo-org branch November 20, 2026 17:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants