Skip to content

feat(plans): growth add-on management cron - #7530

Open
ErickRDev wants to merge 6 commits into
masterfrom
erickr/NAN-6975/add-cron-based-growth-add-on-management
Open

ErickRDev wants to merge 6 commits into
masterfrom
erickr/NAN-6975/add-cron-based-growth-add-on-management

Conversation

@ErickRDev

@ErickRDev ErickRDev commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Run a locked hourly cron to:

  • report enabled growth add-ons on plans that do not support them;
  • activate due add-ons for eligible plans;
  • terminate add-ons whose end date has passed.

Also adds growth_features_starts_at to plans in order to unlock the enabling of growth add-ons on a schedule.

Review in cubic

Run a locked hourly cron to:
- report enabled growth add-ons on plans that do not support them;
- activate due add-ons for eligible plans;
- terminate add-ons whose end date has passed.

Also adds `growth_features_starts_at` to `plans` in order to unlock the
enabling of growth add-ons on a schedule.
@ErickRDev ErickRDev self-assigned this Sep 14, 2026
@linear-code

linear-code Bot commented Sep 14, 2026

Copy link
Copy Markdown

NAN-6975

@github-actions

github-actions Bot commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Preview Deploys

Preview Status URL Deploy Logs Last Updated
Webapp ✅ Ready Preview URL Deploy Logs 15 Sept 2026, 00:57 UTC
Storybook ✅ Ready Preview URL Deploy Logs 15 Sept 2026, 00:57 UTC

@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.

1 issue found and verified against the latest diff

Confidence score: 4/5

  • packages/database/lib/migrations/20260911120000_plans_add_growth_addon_start.cjs lacks an index for the hourly growth_features_starts_at <= snapshot predicate, which could cause each run to scan every plan row and degrade database performance as data grows — add a partial index for this filter.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/database/lib/migrations/20260911120000_plans_add_growth_addon_start.cjs">

<violation number="1" location="packages/database/lib/migrations/20260911120000_plans_add_growth_addon_start.cjs:5">
P2: The hourly growth-addon update filters on `growth_features_starts_at <= snapshot`, but this migration creates no index for that predicate. Add a partial index so each hourly run does not scan every plan row as the plans table grows.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/server/lib/crons/manageGrowthAddons.ts Outdated
Comment thread packages/server/lib/crons/manageGrowthAddons.ts Outdated
* @param {import('knex').Knex} knex
*/
exports.up = async function (knex) {
await knex.raw(`ALTER TABLE plans ADD COLUMN IF NOT EXISTS growth_features_starts_at timestamptz`);

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.

P2: The hourly growth-addon update filters on growth_features_starts_at <= snapshot, but this migration creates no index for that predicate. Add a partial index so each hourly run does not scan every plan row as the plans table grows.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/database/lib/migrations/20260911120000_plans_add_growth_addon_start.cjs, line 5:

<comment>The hourly growth-addon update filters on `growth_features_starts_at <= snapshot`, but this migration creates no index for that predicate. Add a partial index so each hourly run does not scan every plan row as the plans table grows.</comment>

<file context>
@@ -0,0 +1,11 @@
+ * @param {import('knex').Knex} knex
+ */
+exports.up = async function (knex) {
+    await knex.raw(`ALTER TABLE plans ADD COLUMN IF NOT EXISTS growth_features_starts_at timestamptz`);
+};
+
</file context>

@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 1 file (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/server/lib/crons/manageGrowthAddons.ts Outdated

@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 3 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/server/lib/crons/manageGrowthAddons.ts
@ErickRDev
ErickRDev marked this pull request as ready for review September 15, 2026 01:02
@ErickRDev
ErickRDev requested a review from a team September 15, 2026 01:04
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