Skip to content

Commit c1fa9b4

Browse files
author
flow-php
committed
1 parent 99c7d3b commit c1fa9b4

223 files changed

Lines changed: 318 additions & 257 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

β€Žassets/manifest.jsonβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@
159159
"wasm\/php.js": "\/assets\/wasm\/php-854edac03a51f967b58c16849625fb22.js",
160160
"wasm\/php.wasm": "\/assets\/wasm\/php-2c153f5537d6d5ef169b6c07f35bd236.wasm",
161161
"wasm\/phpcsfixer.php.wasm": "\/assets\/wasm\/phpcsfixer.php-65bf51f1ea90e4896971e11e62efef0b.wasm",
162-
"wasm\/tools\/flow.phar": "\/assets\/wasm\/tools\/flow-787e938a16f89842fa01ed79576c29f0.phar",
162+
"wasm\/tools\/flow.phar": "\/assets\/wasm\/tools\/flow-4a801a16e4c58c1728378b0f1978e947.phar",
163163
"wasm\/tools\/php-cs-fixer.phar": "\/assets\/wasm\/tools\/php-cs-fixer-de55dbd75a08d2eac0f0435d4168e6bc.phar",
164164
"wasm\/vendor\/autoload.php.wasm": "\/assets\/wasm\/vendor\/autoload.php-901f7714ee4a437fea3a9d6638722933.wasm"
165165
}
3.36 MB
Binary file not shown.

β€Žchangelog/index.htmlβ€Ž

Lines changed: 59 additions & 53 deletions
Large diffs are not rendered by default.

β€Ždocumentation/api/adapter/postgresql/classes/Flow-ETL-Adapter-PostgreSql-PostgreSqlMetadata.htmlβ€Ž

Lines changed: 37 additions & 23 deletions
Large diffs are not rendered by default.

β€Ždocumentation/api/adapter/postgresql/classes/Flow-ETL-Adapter-PostgreSql-SchemaConverter.htmlβ€Ž

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ <h2 class="phpdocumentor-content__title">
123123
<aside class="phpdocumentor-element-found-in">
124124
<abbr class="phpdocumentor-element-found-in__file" title="src/adapter/etl-adapter-postgresql/src/Flow/ETL/Adapter/PostgreSql/SchemaConverter.php"><a href="files/src-adapter-etl-adapter-postgresql-src-flow-etl-adapter-postgresql-schemaconverter.html"><abbr title="src/adapter/etl-adapter-postgresql/src/Flow/ETL/Adapter/PostgreSql/SchemaConverter.php">SchemaConverter.php</abbr></a></abbr>
125125
:
126-
<span class="phpdocumentor-element-found-in__line">33</span>
126+
<span class="phpdocumentor-element-found-in__line">40</span>
127127

128128
</aside>
129129

@@ -196,7 +196,7 @@ <h4 class="phpdocumentor-element__name" id="method___construct">
196196
<aside class="phpdocumentor-element-found-in">
197197
<abbr class="phpdocumentor-element-found-in__file" title="src/adapter/etl-adapter-postgresql/src/Flow/ETL/Adapter/PostgreSql/SchemaConverter.php"><a href="files/src-adapter-etl-adapter-postgresql-src-flow-etl-adapter-postgresql-schemaconverter.html"><abbr title="src/adapter/etl-adapter-postgresql/src/Flow/ETL/Adapter/PostgreSql/SchemaConverter.php">SchemaConverter.php</abbr></a></abbr>
198198
:
199-
<span class="phpdocumentor-element-found-in__line">37</span>
199+
<span class="phpdocumentor-element-found-in__line">44</span>
200200

201201
</aside>
202202

@@ -240,7 +240,7 @@ <h4 class="phpdocumentor-element__name" id="method_toFlowSchema">
240240
<aside class="phpdocumentor-element-found-in">
241241
<abbr class="phpdocumentor-element-found-in__file" title="src/adapter/etl-adapter-postgresql/src/Flow/ETL/Adapter/PostgreSql/SchemaConverter.php"><a href="files/src-adapter-etl-adapter-postgresql-src-flow-etl-adapter-postgresql-schemaconverter.html"><abbr title="src/adapter/etl-adapter-postgresql/src/Flow/ETL/Adapter/PostgreSql/SchemaConverter.php">SchemaConverter.php</abbr></a></abbr>
242242
:
243-
<span class="phpdocumentor-element-found-in__line">42</span>
243+
<span class="phpdocumentor-element-found-in__line">49</span>
244244

245245
</aside>
246246

@@ -288,7 +288,7 @@ <h4 class="phpdocumentor-element__name" id="method_toPostgreSqlTable">
288288
<aside class="phpdocumentor-element-found-in">
289289
<abbr class="phpdocumentor-element-found-in__file" title="src/adapter/etl-adapter-postgresql/src/Flow/ETL/Adapter/PostgreSql/SchemaConverter.php"><a href="files/src-adapter-etl-adapter-postgresql-src-flow-etl-adapter-postgresql-schemaconverter.html"><abbr title="src/adapter/etl-adapter-postgresql/src/Flow/ETL/Adapter/PostgreSql/SchemaConverter.php">SchemaConverter.php</abbr></a></abbr>
290290
:
291-
<span class="phpdocumentor-element-found-in__line">53</span>
291+
<span class="phpdocumentor-element-found-in__line">60</span>
292292

293293
</aside>
294294

β€Ždocumentation/components/adapters/postgresql/index.htmlβ€Ž

Lines changed: 46 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1520,7 +1520,12 @@ <h1><a id="etl-adapter-postgresql" href="#etl-adapter-postgresql" class="mr-2" a
15201520
<li><a href="#schema-conversion">Schema Conversion</a>
15211521
<ul>
15221522
<li><a href="#creating-a-table-from-a-flow-schema">Creating a Table from a Flow Schema</a></li>
1523-
<li><a href="#steering-the-conversion-with-metadata">Steering the Conversion with Metadata</a></li>
1523+
<li><a href="#steering-the-conversion-with-metadata">Steering the Conversion with Metadata</a>
1524+
<ul>
1525+
<li><a href="#ordering-columns-within-an-index">Ordering Columns Within an Index</a></li>
1526+
<li><a href="#a-column-in-multiple-indexes">A Column in Multiple Indexes</a></li>
1527+
</ul>
1528+
</li>
15241529
<li><a href="#reading-a-flow-schema-back-from-a-table">Reading a Flow Schema back from a Table</a></li>
15251530
<li><a href="#customizing-the-type-mapping">Customizing the Type Mapping</a></li>
15261531
<li><a href="#schema-conversion-dsl-functions-reference">Schema Conversion DSL Functions Reference</a></li>
@@ -2026,12 +2031,12 @@ <h3><a id="steering-the-conversion-with-metadata" href="#steering-the-conversion
20262031
<td>Include the column in the table primary key</td>
20272032
</tr>
20282033
<tr>
2029-
<td><code>PostgreSqlMetadata::indexUnique($name)</code></td>
2030-
<td>Include the column in a named <code>UNIQUE</code> constraint</td>
2034+
<td><code>PostgreSqlMetadata::indexUnique($name, $position)</code></td>
2035+
<td>Include the column in a named <code>UNIQUE</code> constraint, optionally at an explicit position</td>
20312036
</tr>
20322037
<tr>
2033-
<td><code>PostgreSqlMetadata::index($name)</code></td>
2034-
<td>Include the column in a named index</td>
2038+
<td><code>PostgreSqlMetadata::index($name, $position)</code></td>
2039+
<td>Include the column in a named index, optionally at an explicit position</td>
20352040
</tr>
20362041
<tr>
20372042
<td><code>PostgreSqlMetadata::identity($generation)</code></td>
@@ -2045,6 +2050,42 @@ <h3><a id="steering-the-conversion-with-metadata" href="#steering-the-conversion
20452050
</table>
20462051
<p>Columns sharing the same primary key, unique constraint, or index name are grouped together, so composite keys are
20472052
expressed by attaching the same name to several definitions.</p>
2053+
<h4><a id="ordering-columns-within-an-index" href="#ordering-columns-within-an-index" class="mr-2" aria-hidden="true" title="Permalink">#</a>Ordering Columns Within an Index</h4>
2054+
<p>For composite indexes and unique constraints, column order matters. By default columns are ordered the way they appear
2055+
in the schema. Pass an explicit <code>$position</code> (ascending, lower first) to <code>index()</code> / <code>indexUnique()</code> to control the
2056+
order independently of schema field order β€” useful, for example, for a keyset-pagination index where the leading
2057+
column must serve <code>ORDER BY</code>:</p>
2058+
<pre class="language-php" data-controller="syntax-highlight"><code class="language-php">use Flow\ETL\Adapter\PostgreSql\PostgreSqlMetadata;
2059+
2060+
use function Flow\ETL\Adapter\PostgreSql\to_pgsql_schema_table;
2061+
use function Flow\ETL\DSL\{datetime_schema, int_schema, schema};
2062+
2063+
// `id` is field 0, `created_at` is field 1, but the index must lead with `created_at`.
2064+
$table = to_pgsql_schema_table(
2065+
schema(
2066+
int_schema('id', metadata: PostgreSqlMetadata::index('orders_created_at_id_idx', position: 2)),
2067+
datetime_schema('created_at', metadata: PostgreSqlMetadata::index('orders_created_at_id_idx', position: 1)),
2068+
),
2069+
'orders',
2070+
);
2071+
2072+
// =&gt; CREATE INDEX orders_created_at_id_idx ON public.orders (created_at, id)
2073+
</code></pre>
2074+
<p>Columns without an explicit position default to the end (<code>PHP_INT_MAX</code>), and schema order breaks ties β€” so leaving
2075+
positions off keeps the schema-order behavior.</p>
2076+
<h4><a id="a-column-in-multiple-indexes" href="#a-column-in-multiple-indexes" class="mr-2" aria-hidden="true" title="Permalink">#</a>A Column in Multiple Indexes</h4>
2077+
<p>Because each index is tracked under its own metadata key, a single column can belong to several indexes at once. Chain
2078+
<code>merge()</code> to attach more than one:</p>
2079+
<pre class="language-php" data-controller="syntax-highlight"><code class="language-php">$schema = schema(
2080+
int_schema('id', metadata: PostgreSqlMetadata::primaryKey('pk_orders')
2081+
-&gt;merge(PostgreSqlMetadata::index('orders_created_at_id_idx', position: 2))),
2082+
datetime_schema('created_at', metadata: PostgreSqlMetadata::index('orders_created_at_id_idx', position: 1)),
2083+
);
2084+
</code></pre>
2085+
<blockquote>
2086+
<p>Index and unique-constraint names must not contain a colon (<code>:</code>) β€” it is reserved internally as the name/position
2087+
separator and passing one throws an <code>InvalidArgumentException</code>.</p>
2088+
</blockquote>
20482089
<h3><a id="reading-a-flow-schema-back-from-a-table" href="#reading-a-flow-schema-back-from-a-table" class="mr-2" aria-hidden="true" title="Permalink">#</a>Reading a Flow Schema back from a Table</h3>
20492090
<p><code>pgsql_table_to_flow_schema()</code> takes a <code>Flow\PostgreSql\Schema\Table</code> and returns a Flow <code>Schema</code>. Combine it with the
20502091
PostgreSQL library's catalog provider to derive a Flow schema from a live table:</p>
-1.28 KB
Binary file not shown.
1.28 KB
Binary file not shown.
1.7 KB
Binary file not shown.
-1.7 KB
Binary file not shown.

0 commit comments

Comments
Β (0)