Skip to content

Grandfather data already above the free plan limits - #49

Merged
ReinaldoAssis merged 1 commit into
mainfrom
fix/plan-limit-grandfathering
Oct 22, 2026
Merged

ReinaldoAssis merged 1 commit into
mainfrom
fix/plan-limit-grandfathering

Conversation

@ReinaldoAssis

Copy link
Copy Markdown
Owner

Why

Opening the iOS build failed with:

atlas could not open
could not open local data (plan-limit:habits:3)

initialize() saves the snapshot right after loading it. The Rust freemium backstop compared the absolute row counts with the free limits, so any device that already had more than 3 active habits (old install, data synced from a Pro device, or the demo seed) had every write rejected — including the boot save, which left the app stuck on the load-error screen.

What changed

  • db_batch now counts the limited tables before running the statements and passes that snapshot to check_limits.
  • A limit is only enforced when the batch both exceeds it and increases the count. Existing over-limit data is grandfathered: it can be read, edited and deleted, but not grown until the user upgrades or removes items.
  • atlas.test.db bypasses the gating, since demoSnapshot() intentionally has 5 habits and was bricking test mode on mobile.
  • The initial save in initialize() no longer aborts boot; the loaded snapshot is rendered even if that write fails.
  • Docs note the grandfathering rule and the test-DB exemption.

Verification

  • cargo test --manifest-path src-tauri/Cargo.toml --locked (51)
  • npm run check
  • npm test (273)
  • npm run build

Pending manual check on device: reopen the app with the over-limit database, confirm it boots and that editing/deleting works while creating a 4th habit still opens the paywall.

- The boot save (and any other write) was rejected when the database already
  had more items than the free plan allows, e.g. `plan-limit:habits:3`, so the
  app stopped on "could not open local data" and never reached the UI.
- Capture the per-table counts before the batch and only reject batches that
  *increase* a count above its limit. Legacy, synced or previously-Pro data
  stays editable and can only shrink, while creating beyond the limit is still
  blocked.
- Skip the Rust gating for `atlas.test.db`: the demo seed has 5 habits and was
  bricking the test mode on mobile.
- Do not abort boot when the initial save fails; rendering the loaded snapshot
  is more useful than the load-error screen.
@ReinaldoAssis
ReinaldoAssis merged commit 5bac52f into main Oct 22, 2026
4 checks passed
@ReinaldoAssis
ReinaldoAssis deleted the fix/plan-limit-grandfathering branch October 22, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant