Skip to content

Store segment rule JSON alongside existing models #7815

Description

@khvn26

We want to start storing segment rule data as JSON, but not abandon the existing relational model yet. This bounds the scope nicely for easier review, and gives us enough wiggle room to smoke test in prod and/or rollback if needed.

This issue owns the entire write side: every segment write goes through one service that stores rules_data, so no later issue migrates a write site. Reads are unchanged here; the engine and API still read rows.

The writes are switched over completely to rules_data in #7818 — we stop writing the rules and conditions models once that's merged.

Acceptance criteria

  • A segment created or updated through the serializer stores JSON data equal to its reconstructed rule and condition tree, with segment rules and condition rows still written. The nested (n = 2) structure is maintained.
  • The segment versioning history for JSON data is maintained as expected.
  • A cloned segment via has JSON data matching the source segment.
  • A LaunchDarkly import populates both JSON and relational data for rules/conditions.
  • A request body for /api/v1/projects/{project_pk}/segments/{id}/ containing a rule or condition id is accepted; the id is ignored and not persisted in the JSON data.
  • A request flagging a rule or condition with delete: true omits that entry from both the JSON and relational data.
  • The condition-count limit, value-length limit, and WhitelistedSegment exemption are enforced both for JSON and relational data.
  • The backfill migration sets JSON data for every pre-existing live segment.

Metadata

Metadata

Assignees

No one assigned

    Labels

    apiIssue related to the REST API

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions