Skip to content

refactor(ent): remove deprecated billing fields - #4567

Merged
turip merged 1 commit into
mainfrom
feat/remove-deprecated-ent-fields
Jun 25, 2026
Merged

turip merged 1 commit into
mainfrom
feat/remove-deprecated-ent-fields

Conversation

@turip

@turip turip commented Jun 24, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Remove Ent fields that have Deprecated(...) settings across billing, charges, and recursively applied mixins from PR feat: add db support for flatfee/usagebased charge intent overrides #4556.
  • Keep comment-only deprecated fields such as BillingInvoiceLine.credits_applied.
  • Delete the now-unused intentoverride package entirely.
  • Regenerate Ent with the deprecated fields removed and add the SQL migration that drops the old columns.

Notes

  • The split-line and detailed-line tax-code reverse edges were removed from TaxCode as well. Without that, Ent recreates implicit foreign-key columns after the owning fields are removed.
  • The only compile fallout was an obsolete WithTaxCode() eager load for standard invoice detailed lines plus stale tests that wrote now-removed inline override columns directly.
  • After PR feat: add db support for flatfee/usagebased charge intent overrides #4556 merged, this branch was rebased onto latest origin/main.
  • Atlas lint reports the expected destructive-drop diagnostics for the new migration. The repo config treats these as warnings, and make migrate-check exits successfully.

Validation

  • direnv exec . go generate ./openmeter/ent/...
  • direnv exec . make generate
  • direnv exec . go vet -tags=dynamic ./...
  • direnv exec . make migrate-check

Summary by CodeRabbit

  • Bug Fixes
    • Cleaned up billing schema and model layer by removing deprecated invoice/charge/detailed-line fields and relationships (including tax and intent-override related elements).
    • Updated charge and detailed-line wiring to match the streamlined schema, avoiding persistence of stale/unsupported data.
  • Database Migrations
    • Updated migrations to drop deprecated columns on upgrade and restore them on rollback, including a schema-level migration function adjustment.
  • Tests
    • Removed coverage for scenarios where intent-override is absent but stale override columns exist in the database.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8d0889b1-8587-42b5-b330-cd254e83c671

📥 Commits

Reviewing files that changed from the base of the PR and between ef9724d and 72118b7.

⛔ Files ignored due to path filters (57)
  • openmeter/ent/db/billinginvoiceline.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoiceline/billinginvoiceline.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoiceline/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoiceline_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoiceline_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicelinediscount.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicelinediscount/billinginvoicelinediscount.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicelinediscount/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicelinediscount_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicelinediscount_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup/billinginvoicesplitlinegroup.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billinginvoicesplitlinegroup_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billingstandardinvoicedetailedline.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billingstandardinvoicedetailedline/billingstandardinvoicedetailedline.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billingstandardinvoicedetailedline/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billingstandardinvoicedetailedline_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billingstandardinvoicedetailedline_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/billingstandardinvoicedetailedline_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfee.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfee/chargeflatfee.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfee/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfee_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfee_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfeerundetailedline.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfeerundetailedline/chargeflatfeerundetailedline.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfeerundetailedline/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfeerundetailedline_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfeerundetailedline_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeflatfeerundetailedline_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebased.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebased/chargeusagebased.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebased/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebased_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebased_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebasedrundetailedline.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebasedrundetailedline/chargeusagebasedrundetailedline.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebasedrundetailedline/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebasedrundetailedline_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebasedrundetailedline_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/chargeusagebasedrundetailedline_update.go is excluded by !**/ent/db/**
  • openmeter/ent/db/client.go is excluded by !**/ent/db/**
  • openmeter/ent/db/entmixinaccessor.go is excluded by !**/ent/db/**
  • openmeter/ent/db/migrate/schema.go is excluded by !**/ent/db/**
  • openmeter/ent/db/mutation.go is excluded by !**/ent/db/**
  • openmeter/ent/db/runtime.go is excluded by !**/ent/db/**
  • openmeter/ent/db/setorclear.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode/taxcode.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode/where.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode_create.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode_query.go is excluded by !**/ent/db/**
  • openmeter/ent/db/taxcode_update.go is excluded by !**/ent/db/**
  • tools/migrate/migrations/atlas.sum is excluded by !**/*.sum, !**/*.sum
📒 Files selected for processing (13)
  • openmeter/billing/adapter/stdinvoicelines.go
  • openmeter/billing/charges/flatfee/adapter/intentoverride_test.go
  • openmeter/billing/charges/models/intentoverride/flatfee.go
  • openmeter/billing/charges/models/intentoverride/mixin.go
  • openmeter/billing/charges/models/intentoverride/usagebased.go
  • openmeter/billing/charges/usagebased/adapter/intentoverride_test.go
  • openmeter/billing/models/stddetailedline/mixin.go
  • openmeter/ent/schema/billing.go
  • openmeter/ent/schema/chargesflatfee.go
  • openmeter/ent/schema/chargesusagebased.go
  • openmeter/ent/schema/taxcode.go
  • tools/migrate/migrations/20260624135146_remove_deprecated_ent_fields.down.sql
  • tools/migrate/migrations/20260624135146_remove_deprecated_ent_fields.up.sql
💤 Files with no reviewable changes (11)
  • openmeter/billing/charges/models/intentoverride/usagebased.go
  • openmeter/billing/adapter/stdinvoicelines.go
  • openmeter/billing/charges/usagebased/adapter/intentoverride_test.go
  • openmeter/billing/charges/models/intentoverride/flatfee.go
  • openmeter/billing/charges/flatfee/adapter/intentoverride_test.go
  • openmeter/ent/schema/chargesusagebased.go
  • openmeter/ent/schema/taxcode.go
  • openmeter/billing/charges/models/intentoverride/mixin.go
  • openmeter/ent/schema/chargesflatfee.go
  • openmeter/billing/models/stddetailedline/mixin.go
  • openmeter/ent/schema/billing.go

📝 Walkthrough

Walkthrough

The PR removes deprecated billing and charge tax/override schema fields, updates the matching Ent migration, deletes stale-override adapter tests, and makes one billing adapter query comment formatting-only change.

Changes

Billing schema cleanup

Layer / File(s) Summary
Detailed-line and tax-code schema removals
openmeter/billing/models/stddetailedline/mixin.go, openmeter/ent/schema/billing.go, openmeter/ent/schema/taxcode.go
Deprecated detailed-line tax fields, invoice line legacy fields, and TaxCode relationship edges are removed from the billing schemas.
Charge override schema removals
openmeter/ent/schema/chargesflatfee.go, openmeter/ent/schema/chargesusagebased.go
Flat-fee and usage-based charge schemas drop the intentoverride mixins and remove the related detailed-line tax_code edges.
Migration column cleanup
tools/migrate/migrations/20260624135146_remove_deprecated_ent_fields.up.sql, tools/migrate/migrations/20260624135146_remove_deprecated_ent_fields.down.sql
The migration drops the deprecated billing and charge columns in up, and restores them in down.
Adapter test and query cleanup
openmeter/billing/charges/flatfee/adapter/intentoverride_test.go, openmeter/billing/charges/usagebased/adapter/intentoverride_test.go, openmeter/billing/adapter/stdinvoicelines.go
The flat-fee and usage-based adapter suites remove stale-override coverage, and the invoice-line adapter query comment block is reformatted without changing the deleted-line filter.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Suggested labels

kind/refactor, area/billing

Suggested reviewers

  • borbelyr-kong
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change: removing deprecated billing fields from Ent.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/remove-deprecated-ent-fields

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@turip
turip force-pushed the feat/remove-deprecated-ent-fields branch from 0ff1c31 to 1211c66 Compare June 24, 2026 13:54
@turip
turip changed the base branch from main to feat/flat-fee-api-updates June 24, 2026 13:54
Base automatically changed from feat/flat-fee-api-updates to main June 25, 2026 03:38
@turip
turip force-pushed the feat/remove-deprecated-ent-fields branch from 1211c66 to 64dd671 Compare June 25, 2026 03:45
@turip
turip marked this pull request as ready for review June 25, 2026 03:46
@turip
turip requested a review from a team as a code owner June 25, 2026 03:46
@turip turip added the release-note/ignore Ignore this change when generating release notes label Jun 25, 2026
@greptile-apps

greptile-apps Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR removes deprecated Ent billing fields and regenerates the schema layer. The main changes are:

  • Deleted inline intent-override mixins and generated charge override columns.
  • Removed deprecated tax fields from detailed and split billing line schemas.
  • Updated generated Ent code for the removed fields and edges.
  • Added SQL migrations to drop and restore the removed columns.
  • Updated the schema-level invoice migration function for the new detailed-line shape.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
openmeter/ent/schema/chargesflatfee.go Removed the deprecated inline intent-override mixin from flat-fee charges.
openmeter/ent/schema/chargesusagebased.go Removed the deprecated inline intent-override mixin from usage-based charges.
openmeter/billing/adapter/stdinvoicelines.go Removed the obsolete tax-code eager load for standard invoice detailed lines.
openmeter/billing/models/stddetailedline/mixin.go Removed deprecated detailed-line tax fields and their index.
openmeter/ent/schema/billing.go Removed deprecated billing invoice, split-line, discount, and detailed-line fields.
openmeter/ent/schema/taxcode.go Removed reverse tax-code edges for entities that no longer carry tax-code fields.
tools/migrate/migrations/20260624135146_remove_deprecated_ent_fields.up.sql Drops the deprecated columns and updates the invoice schema-level migration function.
tools/migrate/migrations/20260624135146_remove_deprecated_ent_fields.down.sql Restores the removed columns and restores the matching schema-level migration function.

Reviews (3): Last reviewed commit: "refactor(ent): remove deprecated billing..." | Re-trigger Greptile

Comment on lines +11 to +13
-- modify "charge_flat_fees" table
ALTER TABLE "charge_flat_fees" DROP COLUMN "override_feature_key", DROP COLUMN "override_payment_term", DROP COLUMN "override_pro_rating", DROP COLUMN "override_amount_before_proration", DROP COLUMN "override_percentage_discounts", DROP COLUMN "override_name", DROP COLUMN "override_description", DROP COLUMN "override_metadata", DROP COLUMN "override_tax_behavior", DROP COLUMN "override_tax_code_id", DROP COLUMN "override_service_period_from", DROP COLUMN "override_service_period_to", DROP COLUMN "override_full_service_period_from", DROP COLUMN "override_full_service_period_to", DROP COLUMN "override_billing_period_from", DROP COLUMN "override_billing_period_to", DROP COLUMN "override_present", DROP COLUMN "override_intent_deleted_at";
-- modify "charge_usage_based" table

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.

P1 Legacy Override Data Dropped

When existing charge_flat_fees or charge_usage_based rows still hold inline override_* values, this migration drops those columns before copying them into the dedicated override tables. The current charge adapters read overrides from the dedicated override rows, so those charges will come back without their saved intent overrides after the migration.

Fix in Claude Code

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This feature is unused.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I mean those fields are never written to.

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.

Got it — if the inline override_* columns were never written to, there's no data to migrate and the drop is completely safe. My concern was unfounded.

Tip: You can customize Greptile's behavior for this repo with .greptile/rules.md and .greptile/config.json.

@turip
turip force-pushed the feat/remove-deprecated-ent-fields branch from 64dd671 to ef9724d Compare June 25, 2026 04:00
@turip
turip force-pushed the feat/remove-deprecated-ent-fields branch from ef9724d to 72118b7 Compare June 25, 2026 04:12

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

lgtm

@turip
turip merged commit 753caa5 into main Jun 25, 2026
24 of 25 checks passed
@turip
turip deleted the feat/remove-deprecated-ent-fields branch June 25, 2026 08:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note/ignore Ignore this change when generating release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants