Skip to content

Positional schema definition mutations#2454

Merged
norberttech merged 1 commit into
flow-php:1.xfrom
bendavies:feat/schema-positional-mutations
Jun 17, 2026
Merged

Positional schema definition mutations#2454
norberttech merged 1 commit into
flow-php:1.xfrom
bendavies:feat/schema-positional-mutations

Conversation

@bendavies

@bendavies bendavies commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Resolves: #2453

Flow\ETL\Schema previously exposed only add(), which always appends definitions to the end of the schema. This PR adds first-class control over where a definition lands, following the existing API conventions (each method mutates $this and returns it, exactly like add()/remove()/rename()).

New methods on Flow\ETL\Schema:

  • prepend(Definition ...$definitions) - insert at the beginning
  • insertAt(int $index, Definition ...$definitions) - insert at an explicit position
  • addBefore(string|Reference $reference, Definition ...$definitions) / addAfter(...) - insert relative to an existing column
  • moveTo(string|Reference $name, int $index) - relocate an existing column to an index (preserving its definition/metadata)
  • moveBefore(string|Reference $name, string|Reference $reference) / moveAfter(...) - relocate relative to another column
  • reorder(string|Reference ...$names) - reorder by name; any unlisted columns keep their relative order and are appended

Inserting a definition whose name already exists throws SchemaDefinitionNotUniqueException (consistent with add()); an unknown reference throws SchemaDefinitionNotFoundException (consistent with remove()/rename()/replace()). Because schema column order is observable downstream (e.g. PostgreSQL / Parquet / Doctrine DDL generation), this enables declaratively placing a surrogate/primary-key id column first - the motivating use case from the issue.

Change Log


Added

  • Positional schema definition mutations on Flow\ETL\Schema: prepend(), insertAt(), addBefore(), addAfter(), moveTo(), moveBefore(), moveAfter() and reorder()

Fixed

Changed

Removed

Deprecated

Security

Add methods to Flow\ETL\Schema for controlling where definitions land,
instead of add() only ever appending:

- prepend(): insert at the beginning
- insertAt(): insert at an explicit index
- addBefore() / addAfter(): insert relative to an existing column
- moveTo(): relocate an existing column to an index
- moveBefore() / moveAfter(): relocate relative to another column
- reorder(): reorder by name, keeping unlisted columns in relative order

Closes flow-php#2453
@codecov

codecov Bot commented Jun 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.13%. Comparing base (dd25622) to head (7c5cc1a).
⚠️ Report is 1 commits behind head on 1.x.

Additional details and impacted files
@@             Coverage Diff              @@
##                1.x    #2454      +/-   ##
============================================
+ Coverage     85.12%   85.13%   +0.01%     
- Complexity    21162    21186      +24     
============================================
  Files          1599     1599              
  Lines         65336    65409      +73     
============================================
+ Hits          55614    55686      +72     
- Misses         9722     9723       +1     
Components Coverage Δ
etl 88.41% <100.00%> (+0.08%) ⬆️
cli 89.40% <ø> (ø)
lib-array-dot 81.44% <ø> (ø)
lib-azure-sdk 64.44% <ø> (ø)
lib-doctrine-dbal-bulk 93.61% <ø> (ø)
lib-filesystem 85.03% <ø> (ø)
lib-types 90.06% <ø> (ø)
lib-parquet 70.10% <ø> (ø)
lib-parquet-viewer 82.26% <ø> (ø)
lib-snappy 89.38% <ø> (-0.45%) ⬇️
lib-dremel 0.00% <ø> (ø)
lib-postgresql 88.59% <ø> (ø)
lib-telemetry 85.95% <ø> (ø)
bridge-filesystem-async-aws 92.74% <ø> (ø)
bridge-filesystem-azure 90.45% <ø> (ø)
bridge-monolog-http 96.82% <ø> (ø)
bridge-monolog-telemetry 94.11% <ø> (ø)
bridge-openapi-specification 92.07% <ø> (ø)
symfony-http-foundation 78.57% <ø> (ø)
bridge-psr18-telemetry 100.00% <ø> (ø)
bridge-psr3-telemetry 97.84% <ø> (ø)
bridge-psr7-telemetry 100.00% <ø> (ø)
bridge-telemetry-otlp 89.89% <ø> (ø)
bridge-symfony-http-foundation-telemetry 89.47% <ø> (ø)
bridge-symfony-filesystem-bundle 90.20% <ø> (ø)
bridge-symfony-filesystem-cache 98.14% <ø> (ø)
bridge-symfony-postgresql-bundle 93.83% <ø> (ø)
bridge-symfony-postgresql-cache 94.41% <ø> (ø)
bridge-symfony-postgresql-messenger 98.80% <ø> (ø)
bridge-symfony-postgresql-session 93.65% <ø> (ø)
bridge-symfony-telemetry-bundle 80.80% <ø> (ø)
adapter-chartjs 84.05% <ø> (ø)
adapter-csv 91.16% <ø> (ø)
adapter-doctrine 90.79% <ø> (ø)
adapter-elasticsearch 92.07% <ø> (ø)
adapter-google-sheet 99.18% <ø> (ø)
adapter-http 72.34% <ø> (ø)
adapter-json 88.63% <ø> (ø)
adapter-logger 50.00% <ø> (ø)
adapter-parquet 77.70% <ø> (ø)
adapter-text 74.13% <ø> (ø)
adapter-xml 83.40% <ø> (ø)
adapter-avro 0.00% <ø> (ø)
adapter-excel 94.21% <ø> (ø)
adapter-postgresql 91.11% <ø> (ø)
bridge-phpunit-postgresql 75.30% <ø> (ø)
bridge-phpunit-telemetry 80.08% <ø> (ø)
bridge-phpstan-types 0.00% <ø> (ø)
bridge-postgresql-valinor 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@norberttech norberttech added this to the 0.41.0 milestone Jun 17, 2026
@norberttech norberttech merged commit de52d6e into flow-php:1.x Jun 17, 2026
40 checks passed
@github-project-automation github-project-automation Bot moved this from Todo to Done in Roadmap Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Proposal]: Positional schema definition mutations (prepend / addBefore / addAfter / insertAt / move / reorder)

2 participants